Xcode 6.1 Missing required architecture X86_64 in file

人走茶凉 提交于 2019-12-17 04:23:12

问题


In Xcode 6.1 , I am getting error for iPhone 6, iPhone 5s(iOS 7.1) which says

    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_ClientAuthenticator", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
linker command failed with exit code 1

This is what I have for architecture settings perspective

  Architectures : Standard Architectures(armv7, arm64) - $(ARCHES_STANDARD)
  Base SDK : Latest iOS(8.1) 
  Valid Architectures: arm64, armv7, armv7s

  IOS Deployment Target: iOS 6.0

Recently I updated my OS to Yosemite and Xcode from 6.0 to 6.1. I have searched on Stack Overflow for this question which refer to Xcode 5.1 and tried all the given solutions, but nothing has worked.

Update - I tried the changes as suggested in the answer, but I still keep getting the error which says "Missing required architecture X86_64" . On further investigation I found that the file ClientAuthenticator.o which is from my library is not getting built for X86_64 architecture and probably that is the issue? I am looking how it can be built for x86_64.

My new question is what is the difference between arm64 and x86_64? More of it seems like the difference between just the architecture manufacturer, but basic 64-bit architecture remains same.


回答1:


  • The first thing you should make sure is that your static library has all architectures. When you do a lipo -info myStaticLibrary.a on terminal - you should see armv7 armv7s i386 x86_64 arm64 architectures for your fat binary.

  • To accomplish that, I am assuming that you're making a universal binary - add the following to your architecture settings of static library project -

  • So, you can see that I have to manually set the Standard architectures (including 64-bit) (armv7, armv7s, arm64) of the static library project.

  • Alternatively, since the normal $ARCHS_STANDARD now includes 64-bit. You can also do $(ARCHS_STANDARD) and armv7s. Check lipo -info without it, and you'll figure out the missing architectures. Here's the screenshot for all architectures -

  • For your reference implementation (project using static library). The default settings should work fine -

Update 12/03/14 Xcode 6 Standard architectures exclude armv7s.

So, armv7s is not needed? Yes. It seems that the general differences between armv7 and armv7s instruction sets are minor. So if you choose not to include armv7s, the targeted armv7 machine code still runs fine on 32 bit A6 devices, and hardly one will notice performance gap. Source

If there is a smarter way for Xcode 6.1+ (iOS 8.1 and above) - please share.




回答2:


If you are building a universal library and need to support the Simulator (x86_64) then build the framework for all platforms by setting Build Active Architecture Only to No.




回答3:


Many use the build scripts found either here: http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial or here: https://gist.github.com/sponno/7228256 for their run script in their target.

I was pulling my hair out trying to add x86_64, i386, armv7s, armv7, and arm64 to the Architectures section, only to find lipo -info targetname.a never returning these architectures after a successful build.

In my case, I had to modify the target runscript, specifically step 1 from the gist link, to manually include the architectures using -arch.

Step 1. Build Device and Simulator versions xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" xcodebuild -target ${PROJECT_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator -arch x86_64 -arch i386 -arch armv7 -arch armv7s -arch arm64 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"




回答4:


Here's a response to your latest question about the difference between x86_64 and arm64:

  • x86_64 architecture is required for running the 64bit simulator.

  • arm64 architecture is required for running the 64bit device (iPhone 5s, iPhone 6, iPhone 6 Plus, iPad Air, iPad mini with Retina display).




回答5:


I run into exactly the same problem and was following this tutorial https://github.com/jverkoey/iOS-Framework#faq

The way that I made this work is after putting into the scripts into your Aggregate's Build Phase, before you compile, make sure you compile it using an iphone simulator (I used iPhone6) instead of IOS Device.

which will give me 2 slices: armv7 and x86_64, then drag and drop it into new project is working fine for me.




回答6:


My solution was connect my iPhone 6, build on it and I got the project running successfully.

Because I was building for iPhone 6 Simulator.




回答7:


Setting the build active architectures only to No fixed this problem for me.




回答8:


Following changes you have to make that's it(change architecture into armv7 and remove others) :-




回答9:


One other thing to look out for is that XCode is badly handling the library imports, and in many cases the solution is to find the imported file in your project, delete it in Finder or from the command line and add it back again, otherwise it won't get properly updated by XCode. By XCode leaving there the old file you keep running in circles not understanding why it is not compiling, missing the architecture etc.




回答10:


I use lipo command to combine two built static libraries manually.

EX: I have a static library(libXYZ.a) to build.

I run build for Generic iOS Device and got Product in Debug-iphoneos/

$ lipo -info Debug-iphoneos/libXYZ.a
Architectures in the fat file: Debug-iphoneos/libXYZ.a are: armv7 arm64

Then I run build for any iOS Simulator and got Product in Debug-iphonesimulator/

$ lipo -info Debug-iphonesimulator/libXYZ.a
Architectures in the fat file: Debug-iphonesimulator/libXYZ.a are: i386 x86_64

Finally I combine into one to contain all architectures.

$ lipo -create Debug-iphoneos/libXYZ.a Debug-iphonesimulator/libXYZ.a -output libXYZ.a
$ lipo -info libXYZ.a
Architectures in the fat file: libXYZ.a are: armv7 i386 x86_64 arm64



回答11:


If you are having this problem in react-native projects with one of the external library. You should remove the project and use react-native link <package-name> again. That should solve the problem.



来源:https://stackoverflow.com/questions/26552855/xcode-6-1-missing-required-architecture-x86-64-in-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!