【问题标题】:Xcode 6.3 swift framework: Undefined symbols for architecture x86_64Xcode 6.3 swift 框架:架构 x86_64 的未定义符号
【发布时间】:2016-10-03 01:16:21
【问题描述】:

我更新到 Xcode 6.3,但现在我的项目(框架)将不再构建。这是一个纯粹的快速项目。我的所有文件都正确编译(检查了“编译 swift 源文件”部分),但我的测试出现链接错误(myProjectTests.xctest):

    Undefined symbols for architecture x86_64:
  "__TWPSiSs10Comparable14MathEagleTests", referenced from:
      __TFC14MathEagleTests11MatrixTests45testRandowWithDimensionsIntervalGeneratorInitfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests21testSubscriptRangeSetfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests35testSubscriptRowRangeColumnRangeSetfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests30testSubscriptRowRangeColumnSetfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests30testSubscriptRowColumnRangeSetfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests13testMatrixMapfS0_FT_T_ in MatrixTests.o
      __TFC14MathEagleTests11MatrixTests24testMatrixMapPerformancefS0_FT_T_ in MatrixTests.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

奇怪的是 Comparable 是一个 swift 内置协议,所以我认为它与我的代码无关? 所有引用也来自我的测试文件,所以它不是我的主要项目......

【问题讨论】:

  • 最好将解决方案作为答案而不是嵌入到问题中
  • 我把它移到了一个答案,就像你说的那样。

标签: swift xcode6


【解决方案1】:

总是在升级 Xcode 后进行干净的构建:

  • 产品 -> 清洁
  • 产品 ->(按住 Alt 键)清理构建文件夹

然后转到Window->Projects,选择您的项目并删除派生数据。

然后再次编译。

【讨论】:

  • 我试过了,但是没用……难道我已经搞砸了?
【解决方案2】:

我在实现 CocoaPods 并且没有将目标的 Other Linker Flags 设置为 $(inherited) 时遇到此错误

【讨论】:

  • 我尝试了你所说的,但我仍然得到错误......我也没有用 CocoaPods 实现任何东西......无论如何感谢你的回答! :)
【解决方案3】:

我终于找到了解决方法。我使用了几个这样的协议:

extension Int: Addable, Negatable, Substractable, Multiplicable, Dividable, Modulable, Powerable, SetCompliant, BasicMathValue, FullMathValue, MatrixCompatible {}

我认为该错误是由于其中一些协议使用 Comparable 协议这一事实引起的,例如:

protocol FullMathValue: Equatable, Comparable, Addable, Negatable, Substractable, Multiplicable, Dividable, Powerable, SetCompliant, IntegerLiteralConvertible {}

当我明确地将 Comparable 协议添加到扩展中时,一切正常:

extension Int: Comparable, Addable, Negatable, Substractable, Multiplicable, Dividable, Modulable, Powerable, SetCompliant, BasicMathValue, FullMathValue, MatrixCompatible {}

奇怪的是,错误只由 Int 和 UInt 类型引起,所以所有 Int8, ... 和 UInt8, ... 也是如此。 Float 和 Double 没有造成任何问题。

这是我需要报告的错误,还是对此行为有解释?

【讨论】:

    猜你喜欢
    • 2015-10-26
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 2015-11-24
    • 2013-03-09
    • 2013-02-07
    相关资源
    最近更新 更多