Zbar library for iphone 5 (armv7s)

(updated 02/10/2013)

Updated procedure for XCode 5: http://stackoverflow.com/questions/18740304/linker-error-in-xcode-5/18937831#18937831

(updated 08/10/2012)

In this moment the great qr/bar code reader library ZBar (SourceForge link) don’t work on iPhone 5 simply because no one has re-compiled the library for armv7, and if you try to use this lib in you armv7s ready ios project you obtain:

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/rainbird/Desktop/myapp/iFileManager/iFileManager/ZBarSDK/libzbar.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

here two solutions:
The easy and ready to cook solution: Download and include my re-compiled library (support armv6-7-7s and i386) from HERE (note: no warranty, no support, nothing, if don’t work delete it ;) )

The advanced solution: re-compile yourself the libzbar.a following this steps:

1 – Download the source code (you must have Mercurial for mac):

hg clone http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar
cd zbar 
hg checkout iPhoneSDK-1.2.2 (20/03/2013 new version available? hg checkout iPhoneSDK-1.3.1)
open iphone/zbar.xcodeproj

2 – In the xcode project edit the “libzbar” scheme and select Release in Build configuration



3 – Compile libzbar for device AND for simulator, here the configuration:

4 – Find the compiled libzbar.a and go in the folder using Teminal.app, my folder:


In this folder you you should have two sub folder Release-iphoneos and Release-iphonesimulator

5 – using xcode command line tools build you universal lib:

lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a

the end ;) now you can use the libzbar.a created, both in device and simulator.


When you make “Product -> Archive” to avoid the error:

'Cordova/CDVViewController.h' file not found

add this fields:


to Your taget – > Building settings -> Header search paths

facebook comments:

Comments ( 50 )

  1. / Benjamin Myers
    Will you be recompiling this for Xcode 5.1?
    • / Benjamin Myers
      Or iOS 7.1 rather
      • / Federico Cappelli
        I didn't try sorry, your build is failing?
        • / Benjamin Myers
          Yes. The build was working completely fine until I updated to Xcode 5.1 and now it breaks.
          • / Greg Fuller
            I just upgraded to Xcode 5.1 (along with having to restore after a disk crash) & am getting errors. Would love to have a working version for this.
          • / Greg Fuller
            I was just able to get my project running by changing the Architectures settings for Debug and Release to $(ARCHS_STANDARD_32_BIT). It will build and run in the simulator for both the iPhone Retina 4 inch and Phone Retina 64 bit. I actually used the Z-Var 1.13 beta compile for this, downloaded from SourceForge.
  2. / Suresh
    Me too facing the same problem. I have the libzbar.a in the elease-iphoneos/folder
  3. / Mustafa Sozen
    Worked for me too. Great. Thanks.
  4. / トゥミ バッグ 2014
    With thanks! Excellent stuff!
  5. / Bryan
    Worked for me. Thank you.
  6. / Stephen Groom
    Very helpful, thanks
  7. / Mario
    Thank you for these instructions. I saw someone on StackOverflow who had a problem with the ZBar library and pointed them to your tutorial. I also updated it for Xcode 5 and gave you full credit (since I couldn't have written up my own tutorial without yours as a guide). http://stackoverflow.com/a/18937831/155167
  8. / pivasov
    Works for me. Thanks!
  9. / Adrian
    Cheers, a life-saver :-) I was a bit stumped when I hit this problem but your solution worked perfectly!
  10. / Bacem
    Thx you saved my life ;)
  11. / Saad
    Thankyou ... you just saved my life!!!! :)
  12. / Giulio
    Hi, i 've compiled the library and imported into my project , but now i've this error : Undefined symbols for architecture armv7: "_CMSampleBufferGetImageBuffer", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferIsValid", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferDataIsReady", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) "_CMSampleBufferGetNumSamples", referenced from: -[ZBarCaptureReader captureOutput:didOutputSampleBuffer:fromConnection:] in libzbar.a(ZBarCaptureReader.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation). with the simulator is all ok but with my iphone 5 i get the errors..Can you please help or send me a library that work with iphone 5 and Xcode 4.6.1 Thanks
    • / Federico Cappelli
      Hi Giulio, have you imported CoreMedia framework in your project? In any case this post is a little bit old, please check the official distribution
  13. / Olle Lind
    Well done, worked perfectly!
    • / Giulio
      Hi can you please send me your library ? my library doesn't seems to work yet!!!.
  14. / ben ho
    note that the current version is 1.3.1, so you'll have to use hg checkout iPhoneSDK-1.2.2 to get the current version
  15. / Yazar Baby
    Thank you very much.
  16. / Priya
    Thanks, your recompiled Lib helped me...
  17. / RviBYZmfcTE
    Having been merely looking at helpful blog articles with regard to the project research when My partner and i happened to stumble on yours. Thanks for this practical info!
  18. / Rishi Arora
    Thanks for the detailed step-by-step post! Saved a lot of time.
  19. / Adrian
    Thanks Federico, for the instructions and also for providing a ready-to-go package - very much appreciated.
  20. / Marcos Vilela
    Thank you very much!
  21. / PJ Caraher
    Thanks much. Your download worked with no problems. You saved me the step of having to build for myself.
  22. / Archie
    Hi! Do you use Twitter? I'd like to follow you if that would be okay. I'm definitely enjoying your blog and look forward to new updates.
  23. / LorenJaffrey
    XCode says build succeeded and the libzbar.a exists in both folders. The one for the simulator works, the other for the device does not, neither does the result if i combine them with the command line tools. Seems pretty odd to me...
  24. / LorenJaffrey
    Yes, i have a libzbar.a in both folders and xcode also says that the build succeeded for both the simulator and the device. I can also combine them with the command line tools... Seems pretty odd to me...
  25. / Simon
    Thank you very much for this, it was of great help. *buys you a virtual pint* Cheers :)
  26. / Mike
    Thanks so much! Great workaround
  27. / Raul
    Hi Federico: Thanks a lot for your detailed instructions to recompile the Zbar library, none of the other solutions I found worked for me. Now my project's back on track. Best regards! Raul
  28. / Dave Haupert
    Thanks so much for this step by step guide. Worked perfect for me the first try!!
  29. / LorenJaffrey
    Hm... i tried your workaround, but still i got the same error as before. Are there any special Build Settings i have to make?
    • / Federico Cappelli
      Hi, I use the zlib default settings, have you cleaned your app (product->clean) and erase the app on the simulator?
    • / Federico Cappelli
      I have added my build configuration
    • / LorenJaffrey
      I added armv6 to Valid Architectures and cleaned the project and now it's working perfectly. Thanks a lot for your help!
    • / LorenJaffrey
      So a new problem appeared. If i only compile the library for the simulator and import it into my project it works just fine. But if i use the library for the Device, or combine them, i'm getting the same old Error, even with cleaning and deleting the app from the Device...
      • / Federico Cappelli
        be sure to follow all step and compile library for RELEASE not DEBUG, check step 2
      • / LorenJaffrey
        I checked all settings twice, the Build Configuration too. The weird thing is, it works for the simulator, but not for the device... I cleaned my project after removing the library, added the freshly compiled library again. -> Same error on device, working perfectly in the simulator... FYI: I'm currently using an iPad3 with the iOS6 GM Seed for testing.

Leave a reply