28

I was using ZBar for scanning in iOS5 and it was working well.

Now after updating to iOS6, its not working. It shows a following error.

    ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12  /MyApp name/ZBarSDK/libzbar.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What is wrong in my side?

pb2q
  • 58,613
  • 19
  • 146
  • 147
sathiamoorthy
  • 1,488
  • 1
  • 13
  • 23

9 Answers9

52

In Xcode, go to the settings of your target, change 'Valid Architectures'

from

armv7,armv7s

to

armv7

This change means your app will not take advantage of possible optimizations the new iPhone5 processor has, but you don't have to wait for 3rd party libraries to upgrade or mess with a hex editor.

marimba
  • 3,116
  • 5
  • 26
  • 29
  • 4
    As noted in the comments on a separate answer, the appropriate way to resolve this is to compile the library to include the correct architecture. Instructions, and a downloadable package, are at http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/ – adriandz Feb 01 '13 at 16:03
  • 2
    Kappe, that's not true. armv7s is a superset of armv7, so anything working on armv7 should work on v7s as well. If the library would contain code which uses armv7s features (i.e. for speed enhancements), you would loose those features. Only if the library would work **only** on v7s, you would have a problem. – marimba Feb 22 '13 at 15:42
  • 1
    adrianz, you're right, compiling the lib is the appropriate way- if you know what you're doing. But we talk about a library that is 1) not enhanced for armv7s, so the recompile would simply add the right flag without changing anything else 2) a complicated piece of code with lots of targets and switches and 3) probably very soon released with the appropriate v7s support anyway. Wether you want to compile a library with all the possible known and unknown problems for yourself instead of waiting for the maintainers to do the same and using this shortcut in the meantime is up to you of course. – marimba Feb 22 '13 at 15:45
  • This worked for me but only after I set version to iOS 6.0 - it still would not build for 6.1 – EHarpham May 25 '13 at 16:38
  • @marimba not working for me i m using xcode 4.6 and device is iphone5. – Jaimin Modi Dec 26 '13 at 11:23
30

i recently faced the same issue. The problem seems to be that the ZBar SDK is not ready for the armv7s architecture.

I solved the problem this way:

  1. Go to the ZBar homepage and navigate to the mercurial repository (direct link)
  2. Download the zbar repository as zip.
  3. Unzip the file and navigate to the subfolder named "iphone".
  4. Open the XCode project.
  5. Delete the "Examples" folder (the folder caused a build error on my machine).
  6. Hit "CMD + B" and build the source.
  7. Find your new libzbar.a file. (User/Library/Developer/Xcode/DerivedData/zbar...)
  8. Replace the old libzbar.a file in your project with the new one.
  9. Hit "CMD + R" and you are good to go.
Microns
  • 361
  • 2
  • 5
  • 2
    This worked when running on device or simulator. When you try to build the product I still get this error. "_OBJC_CLASS_$_ZBarReaderController", referenced from: objc-class-ref in DealElementDisplayController.o "_ZBarReaderControllerResults", referenced from: -[DealElementDisplayController imagePickerController:didFinishPickingMediaWithInfo:] in DealElementDisplayController.o ld: symbol(s) not found for architecture armv7 – kgibbon Nov 08 '12 at 09:24
  • 1
    @kgibbon You are right. If you go with this tutorial (http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/) it will work just fine. The key is to merge the output files. – Microns Nov 26 '12 at 16:31
  • 2
    This does work. Just one thing, when you go to the direct link click on Code and not iPhone and the click "Download Snapshot". The rest of the instructions work perfectly. Thank you. – rharvey Nov 06 '13 at 10:15
21

The hg sources download/re-compilation tutorial is great, but you don't need to do all that.

Just browse to http://sourceforge.net/projects/zbar/files/iPhoneSDK/beta/ and download ZBarSDK-1.3.1.dmg, and everything will work out of the box for the latest architectures (in my case armv7, armv7s).

Update:

Some of you reported issues with ZBarSDK on XCode 5, iOS 7 or architectures arm64... well I went back to this project today and experienced similar issues and found that there is a ZBarSDK library that is compiled to work with iOS 7 at: http://www.nerdvision.net/app-development/ios/zbar-sdk. I Just replaced the old files with the new ones and my project compiled. Note that the Architectures in my project's Build Settings are set to amrv7, arm64 ($ARCHS_STANDARD), Base SDK is set to iOS 8.0 and I have the Build Active Architectures Only flag set to Yes.

There is a question here at SO about this: zbar SDK dont work for armv7s(iPad 4 iOS 7)

Thanks to @cdescours for the tip!

Community
  • 1
  • 1
Oscar Salguero
  • 10,275
  • 5
  • 49
  • 48
2

I have same problem but I just added armv6 and armv7 then it works for iOS6. Just insert armv6.

Adi
  • 5,089
  • 6
  • 33
  • 47
iKambad
  • 351
  • 1
  • 2
  • 13
1

your binary library does not have code for armv7s. So you should recompile it for the current archtitectures.

Andreas Fink
  • 176
  • 3
1

Recompile the source, I download the source code for zbar and compile into new project. It's simple.

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110
gzfrancisco
  • 812
  • 10
  • 14
0

Clone the Mercurial repository and build with Xcode. It's very easy. Here's a link to the repository:

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

Matt Connolly
  • 9,757
  • 2
  • 65
  • 61
0

Came here with the same problem after downloading the tutorial code RDC provided in his blog. Very useful post, but the most helpful answer here was posted by RacZo on 3/29. I just downloaded the original ZBarSDK-1.3.1.dmg image, removed the ZBarSDK from my project and replaced with the original. Done.

knarf
  • 702
  • 1
  • 9
  • 16
0

I am learning IOS development. After few days digging,

Here is the tutorial for installing ZBar SDK.

1, The accepted answer is correct, but with some limitations. (tried, works!)

2, The alternative solution is here. (tried, works!)

3, The best is to build the all different architectures separated then bind them using lipo: Great Solution (tried, brilliant!)

Some readings for understanding those architectures:

http://wanderingcoder.net/2010/07/19/ought-arm/

http://wanderingcoder.net/2011/09/25/compiling-armv7/

Yang
  • 404
  • 7
  • 13