2 Replies
      Latest reply on Nov 22, 2019 7:19 AM by richardmk80
      wenzhizhao Level 1 Level 1 (0 points)

        I am trying to create a XCFramework with the functionality of core data.

        I simplly create a xcdatamodel and one entity in it.

        Something like this:

        @objc(Conversation)
        public class Conversation: NSManagedObject {
        
        }
        
        extension Conversation {
        
            @nonobjc public class func fetchRequest() -> NSFetchRequest {
                return NSFetchRequest(entityName: "Conversation")
            }
        
            @NSManaged public var message: String?
            @NSManaged public var date: Date?
        
        }
        
        }  
        
        

        When I create the XCFramework, it won't compile in the host app.

        (I create the XCFramework by using the xcodebuild -create-xcframework)

        The error is :

        @NSManaged not allowed on computed properties

         

        In the swiftInterface I got something like this:

         

        @objc(Conversation) public class Conversation : CoreData.NSManagedObject {
          @objc override dynamic public init(entity: CoreData.NSEntityDescription, insertInto context: CoreData.NSManagedObjectContext?)
          @objc deinit
        }
        extension Conversation {
          @nonobjc public class func fetchRequest() -> CoreData.NSFetchRequest<xcframeworktest.Conversation>
          @objc @NSManaged dynamic public var date: Foundation.Date? {
            @objc get
            @objc set
          }
          @objc @NSManaged dynamic public var message: Swift.String? {
            @objc get
            @objc set
          }
        }
        
        

         

        My question is: How to not generate the getter and setter for NSManaged attributes when creating the XCFramework?