50

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
yogsma
  • 10,142
  • 31
  • 97
  • 154
  • Are you using a static library or this error while compiling your own project only? – raurora Oct 24 '14 at 17:15
  • Compiling my own project – yogsma Oct 24 '14 at 17:19
  • So, you're using a third-party library, which does not support 64-bit version (referring to `ClientAuthenticator.m`). Try removing arm64 from Target / Build Settings / Architectures / Valid Architectures and then compile? Screenshot - http://i.imgur.com/Rqwr97G.png – raurora Oct 24 '14 at 17:59
  • That library is written by me, how do I make that compatible with 64-bit version? – yogsma Oct 24 '14 at 18:22
  • 1
    So, now you're asking the right question. I'll post an answer. – raurora Oct 24 '14 at 18:41
  • 7
    `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). – boro Jan 17 '15 at 17:17
  • Simple Solution Go to Target ->Linking -> other linker Flag and add $(inherited) in other linker flag in both Debug and Release. – Mihir Oza Feb 03 '16 at 11:11
  • @boro, you have the answer, but post it, not a comment please !!! Thanks anyways – Ashwin G Mar 16 '16 at 15:19
  • @AshwinG thanks, posted: http://stackoverflow.com/a/36197722/1136128 – boro Mar 24 '16 at 10:17
  • @yogsma did u find the solution for the problem? I've tried all the ways but not get the solution. – Ramakrishna Nov 29 '16 at 12:37
  • @Ramakrishna Yes I did – yogsma Nov 29 '16 at 13:40
  • how u solved it? can u please explain me.. – Ramakrishna Nov 30 '16 at 05:10

12 Answers12

54
  • 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 -

enter image description here

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

enter image description here

  • 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 -

enter image description here

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

    enter image description here

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.

Community
  • 1
  • 1
raurora
  • 3,623
  • 1
  • 22
  • 29
  • 1
    Why do you have to specify exclusively ARCHES_STANDARD_INCLUDING_64_BIT , when ARCHES_STANDARD should have 64 bit – yogsma Oct 24 '14 at 19:32
  • 1
    @yogsma Good point. The normal `$ARCHS_STANDARD` now includes 64-bit. You can also do `$(ARCHS_STANDARD)` and `armv7s`. Updating the answer. – raurora Oct 24 '14 at 19:45
  • 1
    @yogsma If this has answered your question, please accept the answer by clicking the check mark icon. This takes it off the "unanswered" list and increases the chance of people answering your future questions. – raurora Oct 26 '14 at 03:01
  • 1
    Thanks, I will, but it has not resolved my issue. I am pretty good at accepting answers if it resolves my issue, sometimes even when it does not. I am still working on it. – yogsma Oct 27 '14 at 20:35
  • 1
    @yogsma Can you explain the nature of the issue? Just add it as an 'Update' to your question - showing what you did after following the above steps. – raurora Oct 28 '14 at 01:32
  • I have cocoaPods installed in my project, and getting same problem in Xcode 6.1. Do you have any suggestion on how to solve this with pods in project – Vinayaka Karjigi Nov 13 '14 at 13:32
  • @VinayakaKarjigi Check the binary, and see which architectures are missing. Accordingly, you have to adjust the Build Settings. You can always raise an issue on Github regarding [Cocoa Pods](https://github.com/cocoapods/cocoapods/issues). Very active repo. – raurora Nov 14 '14 at 02:34
  • I've tried this, but still got just: armv7 arm64 armv7s. No x86_64 – Vladimir Dec 02 '14 at 13:52
  • Using iOS Device as build target gives me: armv7 arm64 armv7s. If i use a certain simulator as build target it gives me: x86_64. How can we have both? – Vladimir Dec 02 '14 at 14:05
  • @Vlad The trick when creating a static library is to make it universal (you get a single .a file irrespective of what your build target is) - see the tutorial under section called 'Universal Binaries' here. Very popular lipo script - http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial – raurora Dec 03 '14 at 06:05
  • Hello Please if you found solution for above given error for iOS 8 and Xcode 6.1 Please share related to zbar... – BalKrishan Yadav Jan 27 '15 at 07:36
  • @BalKrishanYadav Be specific about your question. Try - http://stackoverflow.com/q/22560899/3527656 – raurora Jan 27 '15 at 07:51
  • This is not working, and the answer is not correct. arm and x86 are two different architectures. – Vanya Jan 14 '16 at 16:22
  • @Vanya Feel free to make edits. It was working as of Xcode 6.1 – raurora Jan 16 '16 at 09:28
27

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

David Douglas
  • 10,377
  • 2
  • 55
  • 53
11

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}"

joelc
  • 2,687
  • 5
  • 40
  • 60
  • I think I'm encountering the same problem, but adding -arch for me causes the xcodebuild command to terminate silently without building anything (I'm dumping output of the above to /tmp, and I get to BUILD SUCCEEDED message without -arch, but don't get past `Build settings from command line` message with -arch) – Alexander Tsepkov May 17 '16 at 14:06
  • Fixed, for me `-arch` parameter didn't result in a successful build for some reason, despite setting the ARCHS variable successfully. However, defining `ARCHS='i386 x86_64'` as part of the command itself fixed the issue for me. – Alexander Tsepkov May 17 '16 at 15:12
11

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

boro
  • 852
  • 1
  • 10
  • 14
4

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.

  • 1
    Went through a lot but this did the trick I just needed to build my framework with a simulator selected. Thanks! – jer_francis Jan 20 '17 at 18:07
3

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
allen huang
  • 165
  • 1
  • 4
1

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.

JD - DC TECH
  • 1,193
  • 9
  • 13
1

Setting the build active architectures only to No fixed this problem for me. enter image description here

0

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

Change you have to make

shubham mishra
  • 971
  • 1
  • 13
  • 32
0

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.

BPH
  • 527
  • 6
  • 10
0

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.

Seraj Ahmad
  • 405
  • 6
  • 10
0

I tried using all the above, nothing worked in my case.

I used the SumUp library which was causing this issue.

I fixed it by:

  1. Removing the -ObjC parameters (all of them); in previous SumUp libs they required to have the -ObjC populated with parameters to make it work, however the latest version (xc v4.0.1 at the time of my answer here), the docs says remove it.

That still didn't fix the issue, I was still seeing errors all over the place hence coming to this thread,... however, after playing around with the settings the following fixed it:

  1. Going into "Build Settings" for your project and then changing "Build Active Architectures Only" to "YES", cleaned, Rebuilt, no errors, Finally!
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Heider Sati
  • 2,476
  • 26
  • 28