更新到 Xcode 5 后 - ld:找不到架构 armv7 或 armv7s 链接器错误的符号 [英] After update to Xcode 5 - ld: symbol(s) not found for architecture armv7 or armv7s linker error

查看:29
本文介绍了更新到 Xcode 5 后 - ld:找不到架构 armv7 或 armv7s 链接器错误的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的 iPhone 4S 软件更新到了 iOS 7 Beta 2,当时我正在对一个新应用 (Phonegap) 进行最后的润色……这不是一个好主意!

完成后 Xcode 没有检测到我的 iPhone,所以我安装了 Xcode 5 beta.摆弄它之后,我终于让它检测到我的手机.现在唯一的问题是使用的架构存在错误.

以下是产生的错误:

ld: 警告:忽略文件/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.一个架构 armv7s 的未定义符号:_OBJC_METACLASS_$_CDVCommandDelegateImpl",引用自:MainViewController.o 中的_OBJC_METACLASS_$_MainCommandDelegate_CDVLocalNotification",引用自:- [AppDelegate application:didReceiveLocalNotification:] 在 AppDelegate.o_OBJC_CLASS_$_CDVCommandDelegateImpl",引用自:MainViewController.o 中的_OBJC_CLASS_$_MainCommandDelegate_OBJC_CLASS_$_CDVCommandQueue",引用自:MainViewController.o 中的_OBJC_CLASS_$_MainCommandQueue_OBJC_METACLASS_$_CDVViewController",引用自:MainViewController.o 中的_OBJC_METACLASS_$_MainViewController_OBJC_METACLASS_$_CDVCommandQueue",引用自:MainViewController.o 中的_OBJC_METACLASS_$_MainCommandQueue_CDVPluginHandleOpenURLNotification",引用自:-[AppDelegate application:handleOpenURL:] 在 AppDelegate.o_OBJC_CLASS_$_CDVViewController",引用自:MainViewController.o 中的_OBJC_CLASS_$_MainViewControllerld:找不到架构 armv7s 的符号clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

关于架构应该更改为什么以使其在我的手机上工作的任何想法?(在模拟器上运行良好)

解决方案

简短回答:

  • 从所有静态库的项目构建设置中删除仅构建活动架构(构建设置参数键为ONLY_ACTIVE_ARCH"),或使用NO"覆盖它,如下面的屏幕截图所示:

详细回答:

问题在于,您在主应用程序中链接的静态库libCordova.a"仅针对一种架构(armv7,而不是 armv7s)进行编译.

您可能已经让 Xcode 为您的静态库项目执行所有推荐的更改,而没有阅读这些更改的实际内容.就我自己而言,当我切换到新版本的 Xcode 时,我从来没有费心仔细查看那个信息对话框(下面的屏幕截图)——直到现在.

问题在于,执行这些更改会为调试构建激活一个名为仅构建活动架构的新功能(构建设置参数键是ONLY_ACTIVE_ARCH").原则上,这是 Xcode 的一个非常酷的增强,因为将其设置为 YES 会导致更快的构建时间,因为当您点击运行按钮时,Xcode 只会编译您当前在顶部选择的连接设备的架构.

但是,在静态库中盲目接受这个新参数时,可能会遇到这个bug.当您在连接 armv7 设备时构建了静态库的调试版本,然后在调试主应用程序时,您连接了 armv7s 设备(反之亦然)时,就会出现错误.随后您将收到上述错误(或类似错误).

因此,我的建议是从所有静态库的项目构建设置中完全删除项目级别的 仅构建活动架构 的值.因为如果你看一下iOS的默认值,它是NO.当然,您也可以将设置覆盖为否"以确保设置正确,即使将来默认值会更改(参见第一个屏幕截图).

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 链接器错误的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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