【问题标题】:Linker error comes while running as well as testing the Xcode workspace after updating KIF framework via cocoapods通过 cocoapods 更新 KIF 框架后,在运行以及测试 Xcode 工作区时出现链接器错误
【发布时间】:2013-11-15 23:04:53
【问题描述】:

我有一个 Xcode 工作区,在其中我已更新到 KIF 2.0(通过终端和 pod 文件中的 pod 'KIF' 更新 pod),之后我按照 https://github.com/kif-framework/KIF#configure-the-testing-target(installation 中提供的说明配置了工作区,带有 Cocoapods 部分) .但是当我尝试执行项目以及运行我的测试目标时,它会抛出一个错误,

ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我也检查了这个链接:https://groups.google.com/forum/#!msg/kif-framework/EilvCp2psZA/huUQ3sGpmwQJ。但问题仍然存在。

我该如何纠正它?屏幕截图如下。

当我尝试使用 iPhone 5 运行它时,它显示 5 个链接器错误,例如

ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit, missing required architecture armv7s in file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit (2 slices)
Undefined symbols for architecture armv7s:
  "_OBJC_METACLASS_$_SenTestCase", referenced from:
      _OBJC_METACLASS_$_KIFTestCase in libPods.a(KIFTestCase.o)
  "_OBJC_CLASS_$_SenTestCase", referenced from:
      _OBJC_CLASS_$_KIFTestCase in libPods.a(KIFTestCase.o)
      l_OBJC_$_CATEGORY_SenTestCase_$_KIFAdditions in libPods.a(SenTestCase-KIFAdditions.o)
  "_SenTestToolKey", referenced from:
      +[KIFTestActor load] in libPods.a(KIFTestActor.o)
  "_SenSelfTestMain", referenced from:
      +[KIFTestActor load] in libPods.a(KIFTestActor.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

【问题讨论】:

    标签: ios7 xcode5 cocoapods kif-framework kif


    【解决方案1】:

    最新的可可豆荚版本也存在同样的问题。

    您可以按照以下步骤解决此问题:

    • 选择 Pods 项目
    • 点击构建设置
    • 将“仅构建活动架构”更改为“否”

    【讨论】:

    • 我已经做了你提到的同样的事情。但它仍然显示相同的问题。我已经重新启动了 Xcode 5 并尝试再次运行它。但问题仍然存在。:(
    • 在我所有目标的项目中,build_activ_arch_only 调试部分设置为是。
    • 奇怪,你确定你设置的是Pods项目的key,而不是你的Nexercise_iPhone项目?
    • 是的。我已将 Nexercise_iPhone 项目 build_active_arch_only 设置为否,并将 pods 项目设置为是。
    • 您应该将“仅构建活动架构”从 Pods 项目更改为“否”而不是“是”
    【解决方案2】:

    转到您的目标设置并将 SenTestingKit 添加到 Link binary with libraries。

    【讨论】:

    • 将 SenTestingKit 框架添加到库中没有任何区别.. :(
    • 好的,然后转到项目 Target 上 Info 选项卡下的 Configurations,公开 Debug config 然后选择 KIF Bundle Test Target 并将其指向正确的 KIF pod 配置文件。它应该类似于Pods-<TestTarget>Pods.config
    • 在我的项目目标的信息选项卡中,在自定义 iOS 目标属性下,我可以看到一个配置键,它被设置为 ${CONFIGURATION}。是你指定的那个吗?
    • 我在我的测试目标上添加了一个“libPods-MyProjectTests-KIF.a”到Link Binary With Libraries,它解决了这个问题。
    【解决方案3】:

    删除 XCTest 框架对我有用。我知道这可能是你不想做的事情。

    【讨论】:

      【解决方案4】:

      我在同事的帮助下解决了这个问题。 两步: 1、只需将cocoapods更新到0.29.0,因为0.29.0只是修复了一个bug,更多细节见: https://github.com/CocoaPods/CocoaPods/issues/1558 使用命令: sudo gem 安装 cocoapods 吊舱安装 吊舱更新 2、如果你想在ios设备上运行你的应用,只需将Build Settings->Architectures更改为(Standard Architecture (armv7,armv7s)),

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-03
        • 2016-09-20
        • 2015-05-26
        • 2016-10-16
        • 2015-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多