ℹ Please fill out this template when filing an issue.
All lines beginning with an ℹ symbol instruct you with
what info we expect.
Please remove this line and all above before submitting.
Before you start, are you using the latest CocoaPods release?
A lot changes with Xcode releases that are not backwards compatible.Not an issue about the CocoaPods command line app? Please file an issue in the appropriate repo - https://github.com/CocoaPods
Issues are for feature requests, and bugs; questions should go to Stack OverflowUsing CocoaPods <= 0.39: http://blog.cocoapods.org/Sharding/
Using Xcode 8: Requires CocoaPods 1.1.0 or above.
Issue with Nanaimo not loading:
Please run[sudo] gem uninstall nanaimoand remove all but the latest version.Issues with
pod search? Try deleting your cacherm -rf ~/Library/Caches/CocoaPodsfirst.
Maybe this question related to issue #650.
I am talking about Xcode 8 release notes Core data.
Feature 22223273.
Xcode automatically generates classes or class extensions for the entities and properties in a Core Data data model. Automatic code generation is enabled and disabled on an entity by entity basis, and is enabled for all entities in new models that use the Xcode 8 file format. This feature is available for any data model that has been upgraded to the Xcode 8 format. You specify whether Xcode generates Swift or Objective-C code for a data model using the data model’s file inspector.
Does cocoa pods include automatically generated model classes files into framework?
Does cocoa pods ignore this feature?
Should I create models manually instead?
Hi there! Thanks for the question! This issue was recently fixed, and it will be available in an upcoming release of CocoaPods (probably 1.2.1). In this release, data models included as resources in the podspec will have the appropriate headers generated. Have a great day!
@benasher44 thanks for quick reply! Is there any schedule or possible release date for 1.2.1?
No scheduled date at the moment. We'll be doing more betas in the coming weeks though. Thanks for your patience!
@benasher44 Hey, has this been resolved yet?
I am able to include the .xcdatamodeld resource via 'resource_bundles' in podspec, but I cannot access the NSManagedObject subclass in the core data model.
I've found a workaround, for anyone else in a similar situation and using Xcode 9.4.1
To have CoreData entity classes generated into your cocoapod framework:
Use resources not resource_bundles for your MyFramework.xcdatamodeld directory
s.resource_bundles = {
'MyFramework' => ['MyFramework/Assets/*.png']
}
s.resources = 'MyFramework/Assets/MyFramework.xcdatamodeld'
And to get the NSPersistentContainer in one of your framework classes:
let modelURL = Bundle(for: type(of: self)).url(forResource: "MyFramework", withExtension: "momd")!
let managedObjectModel = NSManagedObjectModel(contentsOf: modelURL)!
let container = NSPersistentContainer(name: "MyFramework", managedObjectModel: managedObjectModel)
To get this to work, CocoaPods has to include some special handling for the data model files that might break in resource bundles. There's a comment here with more info:
and here:
@amorde
I've seen the first note before, but when I read "These need to be added to the compile sources phase" it sounded like xcdatamodeld should be added to 'resource_bundles' or 'source_files', which doesn't work, instead of 'resources'. Spent the last couple days figuring out how to configure it properly
Ah, yeah. I thought we had some validation on that when linting podspecs, but we could probably do a better job of providing information regarding those details
Would that work only with Swift autogenerated files? How does that work with Objective C generated files?
I've found a workaround, for anyone else in a similar situation and using Xcode 9.4.1
To have CoreData entity classes generated into your cocoapod framework:
Use
resourcesnotresource_bundlesfor your MyFramework.xcdatamodeld directorys.resource_bundles = { 'MyFramework' => ['MyFramework/Assets/*.png'] } s.resources = 'MyFramework/Assets/MyFramework.xcdatamodeld'And to get the
NSPersistentContainerin one of your framework classes:let modelURL = Bundle(for: type(of: self)).url(forResource: "MyFramework", withExtension: "momd")! let managedObjectModel = NSManagedObjectModel(contentsOf: modelURL)! let container = NSPersistentContainer(name: "MyFramework", managedObjectModel: managedObjectModel)
This. So much this. I have been pulling my hair out trying to find solid documentation from cocoapods, and this one took the cake. Thank you.
Yes docs for this could definitely be improved. In general, Core Data models which produce NSManagedObject subclasses should be included using the resources DSL and _not_ resource_bundle, so that Xcode will correctly compile them and expose headers to SDK consumers.
Most helpful comment
I've found a workaround, for anyone else in a similar situation and using Xcode 9.4.1
To have CoreData entity classes generated into your cocoapod framework:
Use
resourcesnotresource_bundlesfor your MyFramework.xcdatamodeld directoryAnd to get the
NSPersistentContainerin one of your framework classes: