Core Data classes not generated for test target
This was due to a bug currently in Xcode (8.3.1) where auto-generated NSManagedObject classes (codegen set to "Class Definition") cannot be found on the global path despite the project compiling successfully. The only way around it is to which to manual generation of the NSManagedObject classes by setting codegen for each entity to "Manual/None".
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;
In Xcode 9.1 try adding your .xcdatamodel
to a test target too. All auto-generated class will be imported too.
Select the test target, navigate to Build Settings and search for the setting "Header Search Paths"
Then add the following entry:
$CONFIGURATION_TEMP_DIR/{Project Target Name}.build/DerivedSources/CoreDataGenerated/{Project Name}
Replace the curly brackets with your main target name (not the test target), and your project name, respectively.
Xcode should now be able to find the generated source files when building the test target.