Xcode4 Linking Problem. File was built for archive

2019-01-16 06:12发布

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?

17条回答
贼婆χ
2楼-- · 2019-01-16 06:18

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

查看更多
叛逆
3楼-- · 2019-01-16 06:18

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

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-16 06:23

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.

查看更多
混吃等死
5楼-- · 2019-01-16 06:23

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.

查看更多
乱世女痞
6楼-- · 2019-01-16 06:26

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.

查看更多
相关推荐>>
7楼-- · 2019-01-16 06:27

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.

查看更多
登录 后发表回答