Xcode4 Linking Problem. File was built for archive which is not the architecture being linked (arm6)

IphoneXcode4Static Linking

Iphone Problem Overview


Recently, I switched to Xcode4 and when I compile my project I got following error.

ld: warning: ignoring file /Users/myname/Library/Developer/Xcode/DerivedData/appname-hezrgyqimckztgbdlslkavphdclw/Build/Products/Debug-iphoneos/libTapkuLibrary.a, file was built for archive which is not the architecture being linked (armv6)
Undefined symbols for architecture armv6:
  "_OBJC_CLASS_$_TKLoadingView", referenced from:
      objc-class-ref in RootViewController.o

I opened the TapkuLibrary and checked that it's Architectures set to 'Standard (armv6 armv7)'.

What can I do to fix this problem?

Iphone Solutions


Solution 1 - Iphone

I figured out what caused the problem. I changed 'Build Active Architecture Only' of TapkuLibrary from Yes to No and it compiles with no problem.

Solution 2 - Iphone

I was able to solve this problem by doing the opposite of the accepted answer - I changed the 'Build Active Architecture Only' from NO to YES.

Solution 3 - Iphone

Had the same problem. But the reason was different I suppose. I was using the library.a file built for simulator and trying to run it on device.. came to know that i need different .a files for simulator and device. I hope this helps someone ;)

For example, here I have imported different library files for device and simulator

Solution 4 - Iphone

I met this problem when I upgraded the XCode to 4.5 and iOS to iOS6. For GMGridView, it just happened. Not for simulator, but only for device.

I fixed this by the following steps:

  1. Go to GMGridView project -> Build Settings
  2. Under Setting -> Architectures, select "Standard (armv7, armv7s)"

Then clean all (including DerivedData) and rebuild.

Hope it helps!

Solution 5 - Iphone

Try to remove the armv6 architecture, and compile it only for armv7.

Solution 6 - Iphone

Something else that worked for me was making sure that all sub projects had the architecture set to be armv6 and armv7, making sure to set both the TARGET and the PROJECT of each sub project. After cleaning and rebuilding everything, it worked without a problem.

Solution 7 - Iphone

This solved the problem for me:

Some external library like three20 did extra settings for

Build Settings->Architectures->Any iOS SDK

the value is "armv6 armv7" that different from standard "armv7 armv7s"

drop down and select "Standard", it worked for me.

Solution 8 - Iphone

I managed it by clicking the "unfriendly" Project's (in my case GMGridView). In tab "Architectures", I changed the value from something (I don't remember exactely anymore, I guess it was:) "armv7, armv6s" to "armv7, armv7". After that it worked for me.

Solution 9 - Iphone

I managed to resolve this by just creating a adhoc configuration inside the Tapku info settings ...

XCODE 4, Project > Archive = library not found for -lTapkuLibrary - Issues - devinross/tapkulibrary - GitHub

Solution 10 - Iphone

Make sure the build variants on your projects are set to "normal".

If you are building a project which includes other projects, take a look inside the DerivedData folder for the main project. Examine the archive files with the "lipo -info yourarchive.a". Also, examine the timestamps on these archives. You may find that these libraries are not getting rebuilt or you are trying to link against an old version of the archive which is the wrong architecture.

In my case, I shutdown Xcode and deleted the DerivedData folder for my main project. This forced a full rebuild when I reopened the main project in Xcode 4. The full rebuild caused the i386 archives to be created (or the correct version to be found) & the simulator version to link correctly.

Solution 11 - Iphone

This worked for me :

  1. Click on the offending framework's 'Project' file (xcodeproj).

  2. Go to the "Info" tab for the framework's 'Project' (not 'Target').

  3. Expand 'Configurations' and make sure that both 'Debug' and 'Release' have 2 configurations set--one for the framework's 'Project' and another for the framework's 'Target'. In the case of frameworks the 'Target' compiles to a Library and not an application, so it's easy to get confused.

  4. 'Debug' should have the Project set to 'Debug' and the Library set to 'Shared'

  5. 'Release' should have the Project set to 'Release' and the Library set to 'Shared'

  6. Compile, run, and enjoy.

  7. If you ended up mangling your entire project trying to figure this out, then you might want to double-check your Application's Project build phases (as Gon suggested). The Library should be there highlighted in red, even if it doesn't exist on your drive. If not, as long as it's set to 'Shared' you should be able to add it back again.

  8. If you really really really mangled your project, then you may be forced to blow out your DerivedData folder, as russes suggested. Also, check the 'Organizer', since Xcode has a way of saving crap all over the place.

  9. Oh, and you checked to make sure that 'armv6' is there right? :)

Solution 12 - Iphone

If I get the ignore file warning - I would run lipo -info on ignored file to find it's architecture as below

lipo -info libTapkuLibrary.a

That would print either of i386, armv6, armv7, armv7s, x86_64 etc. In general, that architecture has to match with your target build platform. E.g.

  • i386 = ios simulator or 32 bit build on mac os x
  • armv6 armv7 arm7s = ios device
  • x86_64 = 64 bit build on mac os x

Depending on the mismatch, either you have to rebuild your library for your target platform or change your target platform.

Note: For fat binaries, lipo -info will print a combination of above architectures.

Solution 13 - Iphone

I fixed this problem thanks to another thread where they show that armv6/armv7 is actually a little different than what you think it is: https://stackoverflow.com/questions/4915953/upgrading-to-xcode-4-error-no-architectures-to-compile-for

Solution 14 - Iphone

I tried all the options above and none worked.

This is the right answer:

simply dragging a framework in your project won't link it properly (or something along these lines, in any case)

what you need to do is select the framework you want to add in Build Phases (click on your project's blue icon, then select your project's name under Targets, then the tab Build Phases), see here for more reference.

Solution 15 - Iphone

None of these answers worked for me. (Similar warning message, different static library project). For me it was having configured XCode to honor the build directories of the targets and then having targets build in a local build/ directory that caused the problem. Configuring XCOde to use "Derived data" folder fixed it.

Solution 16 - Iphone

I had this problem with the Three20 library. The thing that finally did it for me was switching the Project Format from Xcode 3.1 to Xcode 3.2 - leaving 'build active arch only' as "no".

Solution 17 - Iphone

Had the same problem, and tried diverse solutions from the page to no avail. I still had a message telling me my library was not build for arm64.

Finally how I resolved it :

  • opened the project.pbxproj for the library in a text editor
  • searched for VALID_ARCHS
  • there were 4 occurrences, 2 of which did not contain arm64
  • I manually added arm64 in the chain (VALID_ARCHS = "arm64 i386 armv7 armv7s")
  • rebuild the lib and it was all right

Seems sometimes the build settings displayed by XCode is incomplete, and doesn't correspond precisely to the make file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSeunghoonView Question on Stackoverflow
Solution 1 - IphoneSeunghoonView Answer on Stackoverflow
Solution 2 - IphoneJosh BrownView Answer on Stackoverflow
Solution 3 - IphoneZarakiView Answer on Stackoverflow
Solution 4 - IphonesonoshinView Answer on Stackoverflow
Solution 5 - IphoneMacmadeView Answer on Stackoverflow
Solution 6 - IphoneAndyDunnView Answer on Stackoverflow
Solution 7 - IphoneValView Answer on Stackoverflow
Solution 8 - IphonetmightyView Answer on Stackoverflow
Solution 9 - IphoneepinomView Answer on Stackoverflow
Solution 10 - IphonerussesView Answer on Stackoverflow
Solution 11 - IphoneDavid Scott KirbyView Answer on Stackoverflow
Solution 12 - IphonekiranpradeepView Answer on Stackoverflow
Solution 13 - IphonepottedmeatView Answer on Stackoverflow
Solution 14 - IphoneGonView Answer on Stackoverflow
Solution 15 - IphonePEZView Answer on Stackoverflow
Solution 16 - IphoneFishStixView Answer on Stackoverflow
Solution 17 - IphoneEino GourdinView Answer on Stackoverflow