Master data is not imported into an existing project

I have a workspace and am trying to add Core Data to it. I went to the project, I want to add Core Data by selecting Target, clicking the + sign in Link Wit Binary Files and adding the basic data structure. This part works great. I can build and run. When I try the following and using this line:

#import <CoreData/CoreData.h> 

I get build errors. These build errors are as follows:

 "ARC Semantic Issue" Pointer to non-const type 'id' with no explicit ownership 

These errors are present in

 NSEntityDescription.h NSManagedObjectModel.h NSMnagedObject.h NSManagedObjectContext.h NSPersistentStore.h 

Does anyone know why I cannot import Core Data into an existing iOS project? Thanks in advance!

+6
source share
4 answers

This should be as simple as adding CoreData.framework to your target:

enter image description here

Click the plus (+) button in the Related Structures and Libraries section

Then in your prefix file (Tabs-Prefix.pch in this case) in the #ifdef __OBJC__ :

 #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #impport <CoreData/CoreData.h> //Added core data here #endif 

If this does not work, you may have an older version of Xcode installed and the paths are confused. It may try to import an earlier structure.

+1
source

In the search paths in the framework, I had an erroneous path that built correctly as soon as I deleted it:

 $(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks 
+2
source

I think this may be related to your entity definitions. Is it possible that you declared objects that use the id attribute name? This is usually the type NSNumber in subclasses of the model, i.e. *id .

It seems that in this case, the compiler, instead of complaining about *id in the class files, points to id in the header files, which is confusing.

-> Try changing attribute names.

0
source

I had the same problem. It was solved using the following steps:

  • Remove the link to CoreData.framework from the Frameworks group in Xcode.
  • Remove CoreData.framework from "Link Binary with Libraries" in the target settings.
  • Close Xcode ( Cmd + Q ).
  • Open the project folder in Finder and delete the CoreData.framework file.
  • Launch Xcode, open your project. Now you can add CoreData.framework to "Link Binary with Libraries".
  • Remember to add #import <CoreData/CoreData.h> to <projectName>-Prefix.pch in Supported Files. The title of my prefix is ​​as follows:

`

 #import <Availability.h> #ifndef __IPHONE_5_0 #warning "This project uses features only available in iOS SDK 5.0 and later." #endif #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> #endif 

`

I do not know how the existence of any file in the project directory can affect compilation of errors, but it works for me.

Hope this helps everyone who reads it.

0
source

Source: https://habr.com/ru/post/953403/


All Articles