【问题标题】:ld:Framework not found for architecture i386ld:找不到架构 i386 的框架
【发布时间】:2016-04-16 06:36:57
【问题描述】:

我正在尝试在我的框架中测试一个方法,并且我编写了一个简单的测试用例。但它无法执行,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 错误。

我也尝试了以下方法:

  • 框架已添加到嵌入式二进制文件框架部分。
  • Embedded contains swift code设置为YES,因为框架包含swift代码。
  • 打包部分中的可执行前缀为空。 (未设置为@executable_path/Frameworks)
  • Runpath 链接中的搜索路径设置为

    $(继承) @executable_path/框架 @loader_path/Frameworks

  • 我还尝试清理项目并重新启动 xcode,然后构建框架。

  • 已删除派生数据。

我不确定可能是什么问题。有什么想法吗?

【问题讨论】:

  • 你最后找到解决办法了吗?

标签: ios swift xcode7.2 xctestcase


【解决方案1】:

这可能是因为该框架不是针对 iOS 模拟器或您的 Mac 编译的(可能您已选择 iOS 设备作为构建目标)。

如果您有权访问框架目标的项目文件,请前往Build Settings 部分并在Build Active Architecture Only 下选择No

希望这会有所帮助!

【讨论】:

    【解决方案2】:

    这意味着V *** ments没有可以为iphone 5等i386手机编译的版本。

    使用此命令从终端编译对我很有用:

    xcodebuild ARCHS = arm64 -scheme <YOUR SCHEME> -workspace <NAME OF WORKSPACE> .xcworkspace / -configuration Debug build
    

    【讨论】:

      猜你喜欢
      • 2017-03-29
      • 1970-01-01
      • 2016-02-09
      • 2016-01-13
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多