Xcode 6.3 swift 框架:未定义的体系结构符号 x86_64

Xcode 6.3 swift framework: Undefined symbols for architecture x86_64

我更新到 Xcode 6.3,但现在我的项目(框架)将不再构建。这是一个纯粹的 swift 项目。我的所有文件都正确编译(检查了 "Compile swift source files" 部分),但我的测试出现链接错误 (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 内置协议,所以我认为它与我的代码没有任何关系? 所有参考也来自我的测试文件,所以这不是我的主要项目...

始终 升级后进行干净构建 Xcode:

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

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

然后重新编译

我在实施 CocoaPods 而不是将我的目标 Other Linker Flags 设置为 $(inherited)

时遇到了这个错误

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

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 没有造成任何麻烦。

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