Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Mach-O Linker Error ZBarSDK error when building for distribution

Tags:

ios6

linker

I just got this same error when using ZBarSDK, a bar scanning library for iOS. It runs fine when I upload it to my development device or test it on the iOS6 simulator. But when I try to run it for Distribution it fails with:

(null): File is universal (3 slices) but does not contain a(n) armv7s slice: /Users/quique123/Documents/iphone apps/ScanThis/ZBarSDK/libzbar.a for architecture armv7s

where libzbar.a is the library from the sdk.

Any ideas?

like image 558
marciokoko Avatar asked Sep 13 '12 02:09

marciokoko


3 Answers

Open up the ZBar code Mercurial code repo

http://zbar.hg.sourceforge.net/hgweb/zbar/zbar/summary

Go to the bz2/zip/gz links to download current source (in preferred format)

http://zbar.hg.sourceforge.net/hgweb/zbar/zbar/archive/fa84e0427c24.tar.bz2 (as of this post date) http://zbar.hg.sourceforge.net/hgweb/zbar/zbar/archive/fa84e0427c24.zip (as of this post date) http://zbar.hg.sourceforge.net/hgweb/zbar/zbar/archive/fa84e0427c24.tar.gz (as of this post date)

Open the 'iphone' subdirectory

Open the 'zbar.xcodeproj' file

In the scheme's menu select libzbar and build your own binary version in the supported architecture

Open the DerivedData for that project and navigate to Build/Products/

Look in all of the folders for libzbar.a

like image 58
sbonami Avatar answered Oct 16 '22 17:10

sbonami


Simply remove the bad architecture from Valid Architectures in Target Aguilar Settings and you're good to go :)

like image 11
marciokoko Avatar answered Oct 16 '22 18:10

marciokoko


When you have your target selected > Build Settings (All) > Architectures > Valid Architectures.

When you get the above error, remove the armv7s (probably says [armv7 armv7s] now) by double clicking the line and select armv7s and press the (-) button.

In my case, this solved the error. Not sure if this will have any downsides further on..

EDIT: now I am sure this has at least one downside: The project is not buildable for an iPhone 5. The solution for that, is recompiling the ZBar sources, as stated here: ZBar library for iPhone 5(ARMV7s)

like image 7
Jacco Avatar answered Oct 16 '22 19:10

Jacco