I use Core Data's automatically generated classes. My project has 3 targets in addition to the test target. For each target, the Core Data classes are properly generated which I verified by inspecting the Derived Data folder. However, classes are not generated for the Test Target despite it being ticked in the Core Data model file. This causes an "undeclared identifier" error when I try to reference one of the Core Data classes in the test target. How can I fix this please?
2 Answers
Answers 1
You do not need extra classes generated for each test target - your import process should import everything, and no files should need to be added to other targets.
Declaring @testable import MyProject
should take care of everything.
In Objective C
@import MyProject;
Answers 2
The Model object autogenerates code which has to be included in your Test project.
Click on your Model object (ends .xcdatamodeld). Select the file tab on the Utility sidebar (The first tab on the right sidebar). Under "Target Membership" add your test target.
Hope that helps. Try to clean the target and build again if it doesn't.
0 comments:
Post a Comment