Reputation: 321
I installed Realm manually, and it is working on my main app. But on the today extension, i can't even import RealmSwift. I apologise if this question is a newbie question, but I've been searching the web and I can't find a proper updated version. I have read https://realm.io/news/tutorial-sharing-data-between-watchkit-and-your-app/ but it's written a year ago and it does not work anymore.
So how do I go about using realm to share data between the main app and the extension?
Thanks for the help!
Upvotes: 2
Views: 3765
Reputation: 15991
Even though that article is quite old (It's not even using Realm Swift! It's using the Objective-C version bridged to Swift!), the principles of using Realm with iOS 8 extensions haven't changed to the point where the information in there has become outdated.
The main points to consider:
RealmSwift.framework
to both your main app, and the extension.containerURLForSecurityApplicationGroupIdentifier
URL. This is the only place where your main app and the extension can share files.Object
subclasses you've made are included in both your main app, and your extension's 'Compile Sources' build phases.Please let me know if you need any more clarification. :)
Upvotes: 6