Master data classes not created for the target

I use automatically generated Core Data classes. My project has 3 goals in addition to a test goal. For each purpose, Core Data classes are correctly generated, which I checked by checking the Derived Data folder. However, classes are not generated for the test purpose, even though it is marked in the Core Data model file. This results in an “undeclared identifier” and “Using undeclared types” errors when trying to reference one of the base data classes for a test purpose. How can i fix this?

+5
source share
4 answers

This was due to an error that is currently contained in Xcode (8.3.1), where the auto-generated NSManagedObject classes (codegen set in the "Class Definition") cannot be found on the global path, despite the successful compilation of the project. The only way around this is to manually create the NSManagedObject classes by setting the codegen for each object to "Manual / None".

+1
source

You do not need additional classes created for each test target — your import process should import everything, and no files should be added to other targets.

The @testable import MyProject should take care of everything.

In Objective C

 @import MyProject; 
+4
source

In Xcode 9.1, try adding your .xcdatamodel to the test target. The entire automatically generated class will also be imported.

+2
source

I noticed in Xcode 9.1 that the Data Model Inspector has a drop-down list for using the module. The selection of the "Current Product Module" using the class definition codec and including the model in the test target compiles without errors. From what I can say, the pieSquared problem noticed doesn't seem to be the problem, but my tests are not exhaustive yet. However, there might be something to try.

0
source

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


All Articles