FedericoCappelli.net Me, my software and a little bit of my life

5Oct/1233

Zbar library for iphone 5 (armv7s)

(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

libzbar_scheme

 

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:

/Users/kappe/Library/Developer/Xcode/DerivedData/zbar-gyozyrpbqzvslmfoadhqkwskcesd/Build/Products

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.

Update:

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

'Cordova/CDVViewController.h' file not found

add this fields:

"$(BUILT_PRODUCTS_DIR)"
"$(OBJROOT)/UninstalledProducts/include"
"$(TARGET_BUILD_DIR)/usr/local/lib/include"

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

facebook comments:

Comments (33) Trackbacks (1)
  1. Well done, worked perfectly!

  2. After switching to the new libzbar.a, the camera view overlay stops working. Do you have any suggestions? If I delete the new libzbar.a and copy the old one back into the project, the overlay shows back up and works fine on older devices. Thanks!

    • with “the new” one you mean a new official release?

      • By new one, I mean the link you have listed above with your version of the zbar library, or the file generated when following your build instructions with the 1.3.1 SDK. The issue occurs either way. By old one I mean the file that comes with the zbar library that’s missing the iPhone 5 support. Thanks.

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

  4. Thank you very much.

  5. Thanks, your recompiled Lib helped me…

  6. 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!

  7. Thanks for the detailed step-by-step post! Saved a lot of time.

  8. Thanks Federico, for the instructions and also for providing a ready-to-go package – very much appreciated.

  9. Thank you very much!

  10. Thanks much. Your download worked with no problems.

    You saved me the step of having to build for myself.

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

  12. 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…

  13. 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…

  14. Thank you very much for this, it was of great help.

    *buys you a virtual pint*

    Cheers :)

  15. Thanks so much! Great workaround

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

  17. Thanks so much for this step by step guide. Worked perfect for me the first try!!

  18. Hm… i tried your workaround, but still i got the same error as before.
    Are there any special Build Settings i have to make?


Leave a comment

(required)


− 1 = two