Xcode 6链接器错误 - 架构armv7的未定义符号 [英] Xcode 6 linker error - Undefined symbols for architecture armv7

查看:169
本文介绍了Xcode 6链接器错误 - 架构armv7的未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到Xcode 6 beta 7(现在仍然使用Xcode 6 GM)后,我无法链接我的Swift应用程序。我收到错误,例如:

After upgrading to Xcode 6 beta 7 (and now still with Xcode 6 GM) I am unable to link my Swift app. I receive errors such as:


架构armv7的未定义符号:
_swift_stdlib_compareNSStringDeterministicUnicodeCollat​​ion,引自:

Undefined symbols for architecture armv7: "_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:

...

ld:找不到架构armv7的符号
clang:错误:链接器命令失败退出代码1(使用-v查看调用)

ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我看过其他SO帖子建议删除Derived Data文件夹和/或使用Clean Build Folder选项来解决此错误,但在我的情况下,该解决方案根本没有帮助。关于我的代码或我正在使用的CocoaPods没有任何改变,因为Xcode 6 beta 5是它最后一次工作。

I have seen the other SO posts that recommend deleting the Derived Data folder and/or using the Clean Build Folder option to get past this error, but that solution didn't help at all in my case. Nothing has changed about my code or the CocoaPods I'm using since Xcode 6 beta 5 which is the last time it worked.

任何想法?

编辑:

错误日志的完整帖子:


'p>有架构arm64未定义符号:
的_swift_stdlib_compareNSStringDeterministicUnicodeCollat​​ion,从引用:
TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject ___ 14fromConnectionGSQCSo19AVCaptureConnection__T_在BarcodeViewController.o
的__TFSs21_arrayConditionalCastU ___ FGSaQ__GSqGSaQ0 _ ,从引用:
TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_在SessionsTableViewController.o
__TFSs15_arrayForceCastU ___ FGSaQ__GSaQ0
中,引用自:
__TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping in RestApi.o在RestApi.o $ B $
__TFC12MyProject7RestApi12resetRestKitfS0_FT_T_:在SessionsTableViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb AttendeesTableViewController.o
__TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController在BarcodeViewController.o
__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_,
__TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController从引用b __TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_在LoginViewController.o
__TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_ BluetoothManager.o
__TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_在LoginViewCo LoginViewController.o
__TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ CheckingViewController.o中的ntroller.o
__TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_
__TFC12MyProject21BarcodeViewController13startScanningSS0_FT_Sb BarcodeViewController.o
...
ld:找不到架构arm64的符号
clang:error :链接器命令失败,退出代码为1(使用-v查看调用)

Undefined symbols for architecture arm64: "_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from: TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject___14fromConnectionGSQCSo19AVCaptureConnection__T_ in BarcodeViewController.o "__TFSs21_arrayConditionalCastU___FGSaQ__GSqGSaQ0_", referenced from: TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_ in SessionsTableViewController.o "__TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from: __TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping in RestApi.o __TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in AttendeesTableViewController.o __TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in SessionsTableViewController.o __TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o "__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from: __TFC12MyProject7RestApi12resetRestKitfS0_FT_T_ in RestApi.o __TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_ in BluetoothManager.o __TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_ in LoginViewController.o __TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_ in LoginViewController.o __TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ in LoginViewController.o __TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ in CheckinViewController.o __TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o ... ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


推荐答案

什么是发生在这里与您的派生数据位置无关。

What's happening here has nothing to do with your Derived Data location.

当构建swift应用程序时,它会经历几个步骤:

When a swift application is built, it goes through several steps:


  • 编写辅助文件

  • Write auxiliary files

创建产品结构

为每个架构编译swift源

Compile swift source for each architecture

复制资源规则plist

Copy resource rules plist

复制应用程序桥接标题

针对每种架构的swift运行时库链接

Link against swift runtime libraries for each architecture

复制应用程序swift m每个架构的模块

Copy application swift module for each architecture

创建应用程序二进制文件

Create the application binary

复制资源构建阶段

将swift标准库复制到应用程序中

Copy the swift standard libraries into the application

将其打包

签名

哇!好多啊。链接swift运行时库时,您的构建失败。它们位于Xcode开发人员目录中的工具链/ XcodeDefault.xctoolchain / usr / lib / swift / iphoneos 中。具体来说,未正确链接的库是 libswiftCore.dylib 。如果您在该库中使用 nm ,则可以看到它定义了您的第一个缺失符号:

Whew! That's a lot. Your build is failing when linking against the swift runtime libraries. They live in Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos inside the Xcode developer directory. Specifically, the library that is not being correctly linked is libswiftCore.dylib. If you use nm on that library, you can see it defines your first missing symbol:

quellish% nm /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib | grep compareNSStringDeterministicUnicodeCollation
00197c8c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
000000000018352c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation

您还可以使用 lipo 查看文件中的架构:

You can also use lipo to see what architectures are in the file:

quellish% xcrun lipo -info /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
Architectures in the fat file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib are: armv7 arm64

它包含armv7和arm64。这不是图书馆架构的问题。

It contains armv7 and arm64. It's not the library architecture that's the problem.

链接swift标准库是行不通的。源代码控制或迁移Xcode版本可能导致您的项目文件丢失了部分链接步骤,或者根本无法找到它需要链接的库。 Xcode项目文件很复杂并且使用了很多引用 - 合并等可能导致关键引用与链接步骤分离。如果没有完整的构建日志并查看您的计算机,则可能无法分辨。

Linking against the swift standard library is not working. It's possible that source control or migrating Xcode versions has caused your project file to drop part of the linking step, or it's simply not able to find the libraries it needs to link against. Xcode project files are complex and use a lot of references - it's possible that a merge, etc. caused a critical reference to be come dissociated from the linking step. Without a full build log and a look at your machine it may not be possible to tell.

您可能猜到,这个库与项目的派生数据位置无关。

This library, as you might guess, has nothing to do with the project's derived data location.

不幸的是,前进的最佳方式是重新创建项目文件。将破坏的项目的构建日志与正确构建的快速项目进行比较可能会提供一些见解,但也可能浪费时间 - 可修复的问题可能是问题,但更可能不是。

The best way to move forward would unfortunately be to recreate the project file. Comparing the build log of the broken project to a swift project that does build correctly may provide some insights, but it may also be a waste of time - something fixable may be the problem, but more likely not.

我会鼓励你提交一个bug并用它包含麻烦的项目文件。

I would encourage you to file a bug and include the troublesome project file with it.

这篇关于Xcode 6链接器错误 - 架构armv7的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆