Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

cordova - After update to Xcode 5 - ld: symbol(s) not found for architecture armv7 or armv7s linker error

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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: Overwrite 'Build Active Architecture Only' to 'NO' or delete it's entry completely to fallback to iOS Default

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. enter image description here

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...