Xcode4 Linking Problem. File was built for archive

2019-01-16 06:14发布

问题:

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?

回答1:

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.



回答2:

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.



回答3:

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



回答4:

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!



回答5:

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



回答6:

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.



回答7:

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.



回答8:

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.



回答9:

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



回答10:

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.



回答11:

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? :)



回答12:

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.



回答13:

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: Upgrading to xcode 4 error No architectures to compile for



回答14:

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.



回答15:

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



回答16:

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.



回答17:

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.