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
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:






May 7th, 2013 - 10:58
Well done, worked perfectly!
May 3rd, 2013 - 00:12
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!
May 3rd, 2013 - 08:14
with “the new” one you mean a new official release?
May 3rd, 2013 - 08:21
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.
March 20th, 2013 - 20:21
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
March 20th, 2013 - 20:22
oops – i mean
hg checkout iPhoneSDK-1.3.1 instead of
hg checkout iPhoneSDK-1.2.2
March 20th, 2013 - 20:29
yes thanks, The post is quite old, I will be modifying with an alert
February 26th, 2013 - 08:06
Thank you very much.
February 20th, 2013 - 12:37
Thanks, your recompiled Lib helped me…
February 9th, 2013 - 01:21
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!
February 4th, 2013 - 13:58
Thanks for the detailed step-by-step post! Saved a lot of time.
February 1st, 2013 - 17:01
Thanks Federico, for the instructions and also for providing a ready-to-go package – very much appreciated.
December 19th, 2012 - 21:45
Thank you very much!
December 6th, 2012 - 21:32
Thanks much. Your download worked with no problems.
You saved me the step of having to build for myself.
October 12th, 2012 - 17:56
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.
October 9th, 2012 - 08:36
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…
October 9th, 2012 - 08:16
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…
October 8th, 2012 - 12:57
Thank you very much for this, it was of great help.
*buys you a virtual pint*
Cheers
October 8th, 2012 - 14:01
http://goo.gl/r4nrt
October 6th, 2012 - 11:18
Thanks so much! Great workaround
October 5th, 2012 - 21:40
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
October 5th, 2012 - 20:20
Thanks so much for this step by step guide. Worked perfect for me the first try!!
October 5th, 2012 - 11:58
Hm… i tried your workaround, but still i got the same error as before.
Are there any special Build Settings i have to make?
October 5th, 2012 - 13:44
Hi, I use the zlib default settings, have you cleaned your app (product->clean) and erase the app on the simulator?
October 5th, 2012 - 13:56
I have added my build configuration
October 8th, 2012 - 08:02
I added armv6 to Valid Architectures and cleaned the project and now it’s working perfectly.
Thanks a lot for your help!
October 8th, 2012 - 08:29
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…
October 8th, 2012 - 08:43
be sure to follow all step and compile library for RELEASE not DEBUG, check step 2
October 8th, 2012 - 09:00
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.
October 8th, 2012 - 09:02
what device do you have? please post here your console error
October 8th, 2012 - 09:04
p.s use http://pastebin.com/ for post code lines
October 8th, 2012 - 09:29
http://pastebin.com/embed_js.php?i=ERxcui20
October 8th, 2012 - 09:48
seems your build for the device failed, do you have libzbar.a in the Release-iphoneos/ folder?