Search code examples
iosswiftrealmshare-extension

iOS Application and Share Extension Are Using Different Realm Databases


I've written a small app with iOS 9/Swift 2 and RealmSwift 1.01. With Realm I just used it out of the box, no special configurations or anything of the like, and the app can insert/update/retrieve data no problem - and I'm using a class specific to do those functions with Realm. I created a Share Extension set up the PodFile, Targets, all that good stuff but the extension, using the same class as the application is not reading the same Realm database. I did a test insert from the Extension (both application and extension being tested in the simulator), and using the Finder and Realm Browser I've found that the app has its copy of a Realm database and the extension has its own copy. Is there anything specific that I need to do to get the app and the extension working off of the same copy/instance of a Realm database? Thanks, Rick


Solution

  • App Groups allows two different apps(and their extension) use the same folder. And here is Apple's guide.