Swift and CoreData Casting issues in test vs non-test

后端 未结 3 920
野的像风
野的像风 2020-12-31 19:39

I\'m using Swift on Xcode 6 with CoreData.

I\'ve read the release notes and have seen this issue about making sure to mark up a core data model with a m

3条回答
  •  既然无缘
    2020-12-31 19:57

    Here is an updated answer that actually worked for me. Using XCode 9.2

    Ok, I figured it out! It's not exactly intuitive though. First, I had to comment out the @objc(EntityName) line in the NSManagedObject subclasses. Then I went back to the default Module defined in the xcdatamodeld (Current Project Module). Then I had to ensure that only my test classes (and NONE of the NSManagedObject subclasses or any other source files) were compiled as part of my test project (this was critical) and @testable import AppName in my test project class files. Now it never trys to use these classes in the AppNameTests module, only AppName and the test projects can only call public or internal code...therefore all is right in the universe, yay!

提交回复
热议问题