我试图在我的框架中测试一个方法,我写了一个简单的测试用例.但它无法执行,xcode给我错误:
ld: framework not found V***ments for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我仔细检查了框架是否添加到嵌入式二进制文件中以及构建阶段部分.
这是我的测试文件:
import XCTest @testable import MYClass class MYClassTests: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } func testExample() { // This is an example of a functional test case. // Use XCTAssert and related functions to verify your tests produce the correct results. } func testPerformanceExample() { // This is an example of a performance test case. self.measureBlock { // Put the code you want to measure the time of here. } } func testInitalization() { // tests pass when I comment the following lines. // let one = MYClass.sharedInstance // XCTAssertNotNil(one, "Failed to create a MYClass instance") } }
当我取消注释上面两行时,我得到了Framework not found错误.
我也尝试了以下方法:
该框架添加在嵌入式二进制文件框架部分中.
嵌入包含swift代码设置YES
,因为框架包含swift代码.
"包装"部分中的"可执行前缀"为空.(它未设置为@ executable_path/Frameworks)
链接中的Runpath搜索路径设置为
$(继承)@ executable_path/Frameworks @ loader_path/Frameworks
此外,我尝试清理项目并重新启动xcode,并构建框架.
删除了派生数据.
我不确定可能是什么问题.有任何想法吗?