问题描述
我刚刚更新了我的iPhone 4S软件到iOS 7 Beta 2,而我正在做一个新的应用程序(Phonegap)的最后一点。不是一个好主意!
完成后Xcode没有检测到我的iPhone,所以我安装了Xcode 5 beta。修复它后,我终于得到它来检测我的手机。现在唯一的问题是使用的架构出现错误。
这里是生成的错误:
ld:warning:忽略文件/ Users / ----------- / Library / Developer / Xcode / DerivedData / testtest-bmnbmujiosugcmgeiceofgcfmsec / Build / Products / Debug-iphoneos /libCordova.a,文件是为了归档而不是被链接的架构(armv7s):/ Users / -------- / Library / Developer / Xcode / DerivedData / testtest-bmnbmujiosugcmgeiceofgcfmsec / Build / Products / Debug -iphoneos / libCordova.a
架构armv7s的未定义符号:
_OBJC_METACLASS _ $ _ CDVCommandDelegateImpl,引用自:
_OBJC_METACLASS _ $ _ MainViewController.o中的MainCommandDelegate
_CDVLocalNotification :
- AppDelegate.o中的[AppDelegate应用程序:didReceiveLocalNotification:]
_OBJC_CLASS _ $ _ CDVCommandDelegateImpl,引用自:
_OBJC_CLASS _ $ _ MainCommandDelegate in MainViewController.o
_OBJC_CLASS _ $ _ CDVCommandQueue ,引用自:
_OBJC_CLASS _ $ _ MainViewController.o中的MainCommandQueue
_OBJC_METACLASS _ $ _ CDVViewController,引用自:
_OBJC_METACLASS _ $ _ MainViewController.o中的MainViewController
_OBJC_METACLASS _ $ _ CDVCommandQueue从
_OBJC_METACLASS _ $ _ MainCommandQueue在MainViewController.o
_CDVPluginHandleOpenURLNotification,引用自:
- [AppDelegate应用程序:handleOpenURL:]在AppDelegate.o
_OBJC_CLASS _ $ _ CDVViewController引用:
_OBJC_CLASS _ $ _ MainViewController.o中的MainViewController
ld:没有为架构armv7s找到符号
clang:error:linker命令失败,退出代码1(使用-v查看调用)
任何关于架构应该改变为什么的想法,电话? (它在模拟器上正常工作)
简短答案:
- 从所有静态库的项目构建设置中删除仅构建活动架构(构建设置参数键为ONLY_ACTIVE_ARCH),与NO,如下面的屏幕截图所示:
详细回答:
$ b
问题是,你在主应用程序中链接的静态库libCordova.a只针对一个架构(armv7,而不是armv7s)进行编译。
你可能让Xcode为静态库项目执行所有推荐的更改,而不读这些更改实际上是什么。说到自己,我从来没有打算仔细看看那个信息对话框(下面的屏幕截图),当我切换到一个新版本的Xcode - 到现在。
问题是执行这些更改会针对调试版本激活一个名为仅构建活动架构的新功能(构建设置参数键为ONLY_ACTIVE_ARCH)。原则上,这是Xcode的一个非常酷的增强,因为设置为YES导致更快的构建时间,因为Xcode只编译您当前选择在顶部的连接设备的体系结构,当你点击运行按钮。 p>
然而,当在静态库中盲目接受这个新参数时,可能会遇到这个错误。当您在连接armv7设备时构建静态库的调试版本,然后,当您调试主应用程序时,您已连接armv7s设备(反之亦然),就会出现该错误。
因此,我的建议是完全删除项目级别的值仅构建活动架构从所有静态库的项目构建设置。因为如果你看看iOS默认,它是NO。当然,您也可以将设置覆盖为NO,以确保设置正确,即使将来默认值将更改(参见第1屏幕截图)。
I just updated my iPhone 4S software to iOS 7 Beta 2 while I was in the middle of putting the final touches on a new app (Phonegap).. not a good idea!
After it was done Xcode didn't detect my iPhone so I installed Xcode 5 beta. After tinkering around with it I finally got it to detect my phone. The only problem now is there is an error with the architecture used.
Here are the errors being produced:
ld: warning: ignoring file /Users/-----------/Library/Developer/Xcode/DerivedData/testtest-bmnbmujiosugcmgeiceofgcfmsec/Build/Products/Debug-iphoneos/libCordova.a, file was built for archive which is not the architecture being linked (armv7s): /Users/--------/Library/Developer/Xcode/DerivedData/testtest-bmnbmujiosugcmgeiceofgcfmsec/Build/Products/Debug-iphoneos/libCordova.a
Undefined symbols for architecture armv7s:
"_OBJC_METACLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_METACLASS_$_MainCommandDelegate in MainViewController.o
"_CDVLocalNotification", referenced from:
-[AppDelegate application:didReceiveLocalNotification:] in AppDelegate.o
"_OBJC_CLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_CLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_CLASS_$_CDVCommandQueue", referenced from:
_OBJC_CLASS_$_MainCommandQueue in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVCommandQueue", referenced from:
_OBJC_METACLASS_$_MainCommandQueue in MainViewController.o
"_CDVPluginHandleOpenURLNotification", referenced from:
-[AppDelegate application:handleOpenURL:] in AppDelegate.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas on what the architecture should be changed to in order to get it to work on my phone? (it's working fine on the emulator)
Short answer:
- Remove Build Active Architecture Only (build setting parameter key is 'ONLY_ACTIVE_ARCH') from all of your static libraries' project build settings or overwrite it with 'NO' like in the screenshot below:
Detailed answer:
The problem is that your static library 'libCordova.a' which you're linking in your main app is only compiled for one architecture (armv7, but not armv7s).
You've probably let Xcode perform all the recommended changes for your static libraries project without reading what these changes actually are. Speaking for myself, I've never bothered to take a closer look at that info dialog (screenshot below), when I switched over to a new version of Xcode -- until now.
The problem is that performing these changes activates for debug builds a new feature called Build Active Architecture Only (build setting parameter key is 'ONLY_ACTIVE_ARCH'). In principle, this is a very cool enhancement of Xcode, because setting this to YES leads to faster building times, as Xcode only compiles the architecture of the connected device you've currently selected at the top when you hit the run button.
However, when blindly accepting this new parameter in a static library, you may run into this bug. The bug occurs when you've built the debug version of a static library while having connected an armv7 device, and then, when you're debugging your main application, you've connected an armv7s device (or vice versa). Subsequently you'll get the error above (or a similar one).
So my recommendation is to completely remove the value at project level for Build Active Architecture Only from all of your static libraries' project build settings. Because if you take a look at the iOS default, it is NO. Of course you can also overwrite the setting to 'NO' to be sure the setting is correct even if in the future the default value will change (cf. 1st screenshot).
这篇关于更新到Xcode 5 - ld:符号(没有找到架构armv7或armv7s链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!