ios Xcode 6 链接器错误 - 架构 armv7 的未定义符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25765352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 6 linker error - Undefined symbols for architecture armv7
提问by davidethell
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:
升级到 Xcode 6 beta 7(现在仍然使用 Xcode 6 GM)后,我无法链接我的 Swift 应用程序。我收到错误,例如:
Undefined symbols for architecture armv7: "_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
...
ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
架构 armv7 的未定义符号:“_swift_stdlib_compareNSStringDeterministicUnicodeCollation”,引用自:
...
ld:找不到架构 armv7 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
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.
我已经看到其他 SO 帖子建议删除派生数据文件夹和/或使用 Clean Build Folder 选项来解决此错误,但该解决方案在我的情况下根本没有帮助。从 Xcode 6 beta 5 开始,我的代码或我使用的 CocoaPods 没有任何改变,这是它最后一次工作。
Any ideas?
有任何想法吗?
EDIT:
编辑:
A full posting of the error log:
错误日志的完整发布:
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)
对于建筑arm64未定义的符号: “_swift_stdlib_compareNSStringDeterministicUnicodeCollation”,从引用: TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject___14fromConnectionGSQCSo19AVCaptureConnection__T_在BarcodeViewController.o “__TFSs21_arrayConditionalCastU___FGSaQ__GSqGSaQ0_”,从引用: 在SessionsTableViewController.o“__TFSs15_arrayForceCastU___FGSaQ__GSaQ0 TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_”从引用:__TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping在RestApi.o __TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController在AttendeesTableViewController.o __TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController在SessionsTableViewController.o __TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb在BarcodeViewController.o “__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_”,从引用:在BluetoothManager在RestApi.o __TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_ __TFC12MyProject7RestApi12resetRestKitfS0_FT_T_。Ø__TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_在LoginViewController.o __TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_在LoginViewController.o __TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_在LoginViewController.o __TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_在CheckinViewController.o __TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb在BarcodeViewController.o ... LD:符号(S)未找到架构arm64铛:错误:连接命令,退出代码失败1(使用 -v 查看调用)o __TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ 在 LoginViewController.o __TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ 在 CheckinViewController.o __TFC12MyProject21BarcodeViewController13start_FT_T_ 在 CheckinViewController.o __TFC12MyProject21BarcodeViewController13start_FT_T_ 代码中找到错误(在 BarcodeViewController13start_FS0_S0_S0 代码中找到了错误,代码为 barcodeViewController13start_S0_S6_S 代码,请参阅代码中的错误:barcode1v 架构代码:o __TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ 在 LoginViewController.o __TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ 在 CheckinViewController.o __TFC12MyProject21BarcodeViewController13start_FT_T_ 在 CheckinViewController.o __TFC12MyProject21BarcodeViewController13start_FT_T_ 代码中找到错误(在 BarcodeViewController13start_FS0_S0_S0 代码中找到了错误,代码为 barcodeViewController13start_S0_S6_S 代码,请参阅代码中的错误:barcode1v 架构代码:
采纳答案by quellish
What's happening here has nothing to do with your Derived Data location.
这里发生的事情与您的派生数据位置无关。
When a swift application is built, it goes through several steps:
当构建一个 swift 应用程序时,它会经历几个步骤:
Write auxiliary files
Create product structure
Compile swift source for each architecture
Copy resource rules plist
Copy application bridging header
Link against swift runtime libraries for each architecture
Copy application swift module for each architecture
Create the application binary
Copy resources build phase
Copy the swift standard libraries into the application
Package it up
Sign it
写辅助文件
创建产品结构
为每个架构编译 swift 源代码
复制资源规则 plist
复制应用程序桥接头
链接每个架构的 swift 运行时库
为每个架构复制应用程序 swift 模块
创建应用程序二进制文件
复制资源构建阶段
将 swift 标准库复制到应用程序中
打包
签字
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:
哇!好多啊。链接 swift 运行时库时,您的构建失败。它们位于Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
Xcode 开发人员目录中。具体来说,未正确链接的库是libswiftCore.dylib
. 如果您nm
在该库上使用,您可以看到它定义了您的第一个缺失符号:
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
You can also use lipo
to see what architectures are in the file:
您还可以使用lipo
查看文件中的架构:
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
It contains armv7 and arm64. It's not the library architecture that's the problem.
它包含 armv7 和 arm64。问题不在于图书馆架构。
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.
链接到 swift 标准库不起作用。源代码管理或迁移 Xcode 版本可能导致您的项目文件删除部分链接步骤,或者根本无法找到它需要链接的库。Xcode 项目文件很复杂,并且使用了大量引用 - 合并等可能导致关键引用与链接步骤分离。如果没有完整的构建日志并查看您的机器,可能无法判断。
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.
不幸的是,最好的方法是重新创建项目文件。将损坏的项目的构建日志与正确构建的 swift 项目进行比较可能会提供一些见解,但这也可能是浪费时间——问题可能是可修复的,但更有可能不是。
I would encourage you to file a bug and include the troublesome project file with it.
我鼓励您提交一个错误并将麻烦的项目文件包含在内。
回答by Brad R
I have solved my issue by deleting all the data in the ~/Library/Developer/Xcode/DerivedData
folder. I read about that in another thread, but ignored it thinking a clean included that process!
我已经通过删除~/Library/Developer/Xcode/DerivedData
文件夹中的所有数据解决了我的问题。我在另一个线程中读到了这个,但忽略了它,认为一个干净的包含该过程!
回答by Tayfundu37
I have Updated on Yosemite, Xcode 6.1. I have updated gem xcodeproj (0.19.4) and cocoapods (0.34.4).
我已经更新了 Yosemite,Xcode 6.1。我更新了 gem xcodeproj (0.19.4) 和 cocoapods (0.34.4)。
I have resolve my conflict by :
我已经通过以下方式解决了我的冲突:
Clearing the Library/Developer/Xcode/DerivedData folder
清除 Library/Developer/Xcode/DerivedData 文件夹
replace in Target -> Build Settings -> Linking -> Other Linker Flags : $(OTHER_LDFLAGS)
在 Target -> Build Settings -> Linking -> Other Linker Flags 中替换:$(OTHER_LDFLAGS)
Check in Target -> Build Phases -> Copy Pods Resources : "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"
签入 Target -> Build Phases -> Copy Pods Resources :“${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh”
回答by Bhavesh Lathigara
1) I face the same problem but just clear the applications from derived data from User/Library/Developer/Xcode/DerivedData
and I am able to run the code.
1)我面临同样的问题,但只需从派生数据中清除应用程序User/Library/Developer/Xcode/DerivedData
,我就可以运行代码。
2) In your case may be, it will run by removing armv7 architecture from build settings. And make sure your compiler is Default Compiler in Build Settings.
2)在您的情况下,它将通过从构建设置中删除 armv7 架构来运行。并确保您的编译器是构建设置中的默认编译器。
Thanks I hope this helpful to you and everyone.
谢谢我希望这对你和每个人都有帮助。
回答by GrandSteph
I solved this issue after trying all that was suggested here with no luck. Like someone said earlier, it's a SourceControl issue.
我在尝试了这里建议的所有内容后解决了这个问题,但没有运气。就像之前有人说的,这是一个 SourceControl 问题。
One of my project files (the one referenced in the error message) was missing from the project browser. However, XCode still had a reference to it (I was going to the class definition when I was selecting "jump to definition" from Xcode GUI).
项目浏览器中缺少我的一个项目文件(错误消息中引用的文件)。但是,XCode 仍然有对它的引用(当我从 Xcode GUI 选择“跳转到定义”时,我将转到类定义)。
As a matter of fact, the project.pbxproj was not listing it. This was probably a Git Issue. In any event, I just recreated the file in the same directory it has been recreated and voila.
事实上,project.pbxproj 并没有列出它。这可能是一个 Git 问题。无论如何,我只是在重新创建的同一目录中重新创建了该文件,瞧。
回答by Sandi Laufenberg-Deku
I am a filly when it comes to iOS Objective C, though I have been coding in several other languages for many years. So I am stabbing around in the dark most of the time with Objective C.
我对 iOS Objective C 一窍不通,虽然我多年来一直在用其他几种语言进行编码。所以我大部分时间都在黑暗中用目标 C 刺伤。
I started having this error, "Undefined symbols for architecture armv7", directly after declaring some "global" variables in my .h file like so:
在我的 .h 文件中声明了一些“全局”变量之后,我开始出现这个错误,“架构 armv7 的未定义符号”,如下所示:
extern NSString *globalNotes;
extern NSString *globalUserCountry;
I was then referring to these variables from the .m file like so:
然后我从 .m 文件中引用这些变量,如下所示:
globalNotes= @"Error (Marker 1010)";
globalUserCountry= @"No result";
THE FIX - To correct this, I changed them to object properties like so:
修复 - 为了纠正这个问题,我将它们更改为对象属性,如下所示:
@property(nonatomic, strong, readwrite) NSString *globalNotes;
@property(nonatomic, strong, readwrite) NSString *globalUserCountry;
And referred to them like so:
并像这样提到他们:
self.globalNotes= @"Error (Marker 1010)";
self.globalUserCountry= @"No result";
That seemed to fix my problem.
这似乎解决了我的问题。
回答by m0thman
'Upgraded' to xcode 6 and swift app wouldn't build for simulator yet would build fine on an iPad - Linker error, undefined symbols for i386 for the simulator.
“升级”到 xcode 6 并且 swift 应用程序不会为模拟器构建,但可以在 iPad 上很好地构建 - 链接器错误,模拟器的 i386 的未定义符号。
Clearing the Library/Developer/Xcode/DerivedData folder worked for me.
清除 Library/Developer/Xcode/DerivedData 文件夹对我有用。
回答by Ralph K
There appears to be a bug in Xcode 6.0.1 that is causing the linker to drop dependencies in existing project files. I have had this same problem across several different projects, new and old, since the 6.0.1 update.
Xcode 6.0.1 中似乎存在一个错误,导致链接器删除现有项目文件中的依赖项。自 6.0.1 更新以来,我在几个不同的新项目和旧项目中遇到了同样的问题。
The easy 'fix' is to just trash your entire 'Derrived Data' and all build files (i.e. manually clean the project) and then rebuild after a fresh Xcode restart. Magically, the linker now finds all the missing architectures/symbols.
简单的“修复”就是删除整个“派生数据”和所有构建文件(即手动清理项目),然后在全新的 Xcode 重新启动后重建。神奇的是,链接器现在可以找到所有缺失的架构/符号。
NOTE: I have had several incompatible v-table crashes caused by this same bug. The C++ linker appears to be generating incomplete linkages, causing absurd errors where there are no realerrors to be found. Again, just rebuild from a clean state and .. ta da.. save yourself a LOT of headache and wasted time tracking down a non-issue.
注意:我有几个不兼容的 v-table 崩溃是由这个相同的错误引起的。C++ 链接器似乎正在生成不完整的链接,从而导致在找不到真正错误的情况下出现荒谬的错误。同样,只需从干净的状态中重建,然后...... ta da.. 为自己省去很多头痛和浪费时间追踪非问题的麻烦。
回答by user3562213
I had somewhat similar problem (a linker error from Apple's framework). As it turned out, the problem was that I was missing the library LocalAuthentication.framework. I am wondering if maybe you need to delete the Foundation.framework from the Build Phase tab (in the Link Libraries section), and then re-add it? Maybe that will solve the problem?
我有一些类似的问题(来自 Apple 框架的链接器错误)。事实证明,问题是我缺少库 LocalAuthentication.framework。我想知道您是否需要从 Build Phase 选项卡(在 Link Libraries 部分)中删除 Foundation.framework,然后重新添加它?也许这会解决问题?
回答by Joshua Nozzi
This seems to be caused (for most) by linking a third-party library that does not support the requested architecture.
这似乎是(对于大多数)由链接不支持所请求架构的第三方库引起的。