25

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?

marciokoko
  • 4,988
  • 8
  • 51
  • 91
  • I posted a solution that worked quite fine. Check it out here http://stackoverflow.com/a/12561312/1693858 – Microns Sep 24 '12 at 08:28

7 Answers7

16

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

sbonami
  • 1,892
  • 17
  • 33
  • I'm trying to use this advice, but I can not seem to find the libzbar.a file after the build. The only libzbar file that is generated is a .rc file. Any tips on what settings I might have missed? – nj. Oct 01 '12 at 14:09
  • 1
    @nj i've edited my answer to better direct you through the final steps, hope that helps. – sbonami Oct 02 '12 at 15:25
  • Hi Scott, This solution worked for me. However, I have to use two libzbar.a files - 1. For simulator 2. For Device. Is there any way by which i can use only one libber.a for both. While compiling libber.a i have set iOS device for device and iOS simulator for the simulator. Am I doing something wrong? – Bhagyashree Dayama Nov 26 '12 at 07:40
  • 2
    I got the answer here: http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/ – Bhagyashree Dayama Nov 26 '12 at 08:04
11

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

marciokoko
  • 4,988
  • 8
  • 51
  • 91
  • 1
    Later on you might want to rebuild the zbar to support the arm7s. This thread might be good starting point http://sourceforge.net/projects/zbar/forums/forum/1072195/topic/5081620 – Zdenek Sep 13 '12 at 05:32
  • 1
    Caution: by doing this your app will no longer be available for iPhone 5, which is running on armv7s architecture. – syntagma Apr 19 '13 at 20:49
  • How to remove? I mean from which folder. Give me some steps – Gajendra K Chauhan Sep 21 '13 at 04:17
7

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)

Jacco
  • 463
  • 6
  • 8
4

You can download the new build of ZBarSDK in URL below.

http://sourceforge.net/projects/zbar/files/iPhoneSDK/beta/

Aruna
  • 701
  • 10
  • 26
1

I just replaced in Build Settings / Valid Architectures: "armv7" for 2 rows "armv6" and "armv7"

(Usually I used to get this linker error only when submitting to iTunes, but not debugging in device)

Pablo
  • 11
  • 1
0

Just remove the "armv7s", this will work :)

Nuno Ferro
  • 1,261
  • 12
  • 17
0

Set 'Build Active Architecture Only' to YES for release. I fixed my problem by doing so as I was facing this same problem.

sam
  • 117
  • 10