So far, using both Swift files from the app target and Swift files from the test target in Objective-C unit tests does not work.
I've found that in order to have access to both types of Swift files, you need to have separate <target>-swift.h
files, one for the app target files and one for the test target files so that Objective-C interfaces are generated for both app target Swift files and test target Swift files (otherwise only one or the other would be generated).
When I do this however, the build fails with an error in the <test target>-swift.h
file saying next to the line @import <app target>;
that Module <app target> not found
.
This happens even though:
- Test target's "Host Application" is set to the app target
- "Allow testing Host Application APIs" is checked
- "Defines Module = Yes" in the app target
- I added both
$CONFIGURATION_TEMP_DIR/<project name>.build/DerivedSources
and$CONFIGURATION_TEMP_DIR/<app target>.build/DerivedSources
to both "Header Search Paths" and "User Header Search Paths"
I do not want to give the Swift files membership to both targets as the entire point of what I'm doing is to remove all app target files from the test target.
Is there a solution to this problem or is there just a limitation with Xcode that prevents us from using both app and test target Swift files in Objective-C unit tests?
Note: this project does have cocoapods integrated, but I'm not sure if this is relevant.