

(make sure the language selected is swift) 3.
#Swift share core data with extension code#
Under File -> New File create a new empty source file with Code File template. (the choice of the platform doesn't matter) 2. You can share your model (.momd) and managed object subclasses with extension just by making sure they are included in extension target as well. In Project template, choose Shared Project.

Something like: NSString *containerPath = containerURLForSecurityApplicationGroupIdentifier:YOUR_SECURITY_APP_GROUP].path NSString *sqlitePath = [NSString containerPath, in your extension just create persistent store coordinator with managed object contexts using database in shared container. In order to achieve that, you need to configure App Groups and make sure that your host app configures the Core Data stack using your shared container (so your store is accessible in extension as well). like a Core Data persistent store, and uses CloudKit to share that data with.
#Swift share core data with extension how to#
And sometimes no sense to implement a data storage for. How to take advantage of Swift 4.2, iOS 12, and Xcode 10 to create insanely. Swift packages are a convenient way to separate concerns, for instance, by extracting the persistent. Sometimes iOS applications have some extensions, for example Today Extensions, or Apple Watch Extensions. When creating an app, its architecture should be modular, so that dependencies can be recognized and managed clearly and as simple as possible. (CloudKit does provide some broader data sharing.) Core Data is a powerful data-persistence tool that is part of Cocoa. What you really want is to access your persistent store (most likely a SQLite database). Let’s add a Core Data manager and model to a Swift package.
