Any suggestions how to do this for macOS?
Post
Replies
Boosts
Views
Activity
I have created a sample project on GitHub that demonstrates this issue. SectionedFetchRequest_Experiment Explanations and expectations are in the comments of the ContentView.
While waiting formal solution, as a workaround, the general idea is to receive NSManagedObjectContextDidSave notifications and then check to see if any of the updated objects have any relationship to any of the objects in the SectionedFetchResults. If so, the nsPredicate dynamic property is changed to cause the results to be refetched, which will in turn cause the ContentView to be updated.
The GitHub sample project above has been edited to incorporate this workaround. Just uncomment the .onReceive view modifier to enable the workaround.
I still believe this work should be handled by the @SectionedFetchRequest property wrapper itself. However, I'm sure that a completely general solution would require more than what I have implemented here. I will submit a request via Feedback Assistant for this issue.
I have found a workaround for this problem by letting Xcode generate the Info.plist, then ignoring the CFBundleVersion key that it generates. I then ALSO supply a minimal explicit Info.plist file in Build Settings -> Packaging that only contains a single user defined MyBundleVersion key:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MyBundleVersion</key>
<string>68</string>
</dict>
</plist>
Then I use PlistBuddy to increment MyBundleVersion instead of CFBundleVersion. and then reference the MyBundleVersion key in code:
let myBundleVersion = Bundle.main.infoDictionary?["MyBundleVersion"] as? String