I have an app which has Objective-C and Swift combined. It has an XCTest target. I have a static framework written in Objective-C which is linked to a main target and is used by main target and test target.
I have tested 3 different cases, in which two of them compile but with warnings, while I want to see no warnings when I run my tests:
1) Static framework is not linked to test target (via Link Binary With Libraries
), but is included to the test target's Framework search paths
. The test target compiles but I have warning:
ld: warning: Auto-Linking supplied '.../MyStaticFramework/MyStaticFramework.framework/MyStaticFramework', framework linker option at /.../MyStaticFramework/MyStaticFramework.framework/MyStaticFramework is not a dylib
2) Static framework is linked to test target (via Link Binary With Libraries
), and is included to the test target's Framework search paths
. The test target compiles but I have warning:
objc[2653]: Class MyStaticFrameworkClassA is implemented in both /.../MyApp.app/MyApp and /.../MyApp.app/PlugIns/Tests.xctest/Tests. One of the two will be used. Which one is undefined.
3) Static framework is not linked to test target (via Link Binary With Libraries
), and is not included to the test target's Framework search paths
. The test target does not compile:
In file included from ".../Tests/.../TestFile.m:13:
.../Build/Intermediates/MyApp.build/Debug-iphonesimulator/Tests.build/../MyApp.build/DerivedSources/MyApp-Swift.h:103:9: fatal error: module 'MyStaticFramework' not found
@import MyStaticFramework;
^~~~~~~~
来源:https://stackoverflow.com/questions/39544257/error-in-linking-of-a-static-ios-framework-to-both-apps-and-xctest-targets