1

I've followed this bar code scanner tutorial http://rdcworld-iphone.blogspot.com.au/2013/03/how-to-use-barcode-scanner-br-and-qr-in.html which runs fine in the simulator. However it says "Build Failed" when I connect my iPhone and attempt to build it. There are no errors. My phone version is 7.1.2 if that helps.

What process should I follow to find what the cause/s of the failure are?

Edit:

I am not using an _ or space in the project name.

Edit:

Error log for iPhone:

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

The error log for iPhone 4 64 bit simulator:

ld: warning: ignoring file /Users/airefrig/Documents/BarcodeScannerDemo/BarcodeScannerDemo/ZBarSDK/libzbar.a, missing required architecture x86_64 in file /Users/airefrig/Documents/BarcodeScannerDemo/BarcodeScannerDemo/ZBarSDK/libzbar.a (3 slices)
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
      objc-class-ref in ViewController.o
  "_ZBarReaderControllerResults", referenced from:
      -[ViewController imagePickerController:didFinishPickingMediaWithInfo:] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(null): Ignoring file /Users/airefrig/Documents/BarcodeScannerDemo/BarcodeScannerDemo/ZBarSDK/libzbar.a, missing required architecture x86_64 in file /Users/airefrig/Documents/BarcodeScannerDemo/BarcodeScannerDemo/ZBarSDK/libzbar.a (3 slices)

(null): "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:

(null): Objc-class-ref in ViewController.o

(null): "_ZBarReaderControllerResults", referenced from:

(null): -[ViewController imagePickerController:didFinishPickingMediaWithInfo:] in ViewController.o

(null): Symbol(s) not found for architecture x86_64

(null): Linker command failed with exit code 1 (use -v to see invocation)

Edit: I've got it to work fine on the iPhone by downloading and using the latest zbar sdk framework. Now however the simulator doesn't build as it wants the old one!

Anyone have an idea how to make both the phone and simulator happy?

Edit 2:

I got it working use the old libraries, but not the latest which is what I have to do for work. For the old libraries I did the following:

1) Create a new app and make it universal. 2) Follow the normal tutorial steps except use a storyboard not a xib file and set the project to use that for both iphone and ipad. Also don't put in the code near the end of the tute which specifies which Xib to use since I'm not using one! 3) In build settings set the Architectures and Valid Architectures to "armv7" 4) In build settings set Build Active architecture only to YES

What I've done just recently is to remove the old ZBar libraries and replace them which these http://www.nerdvision.net/app-development/ios/zbar-sdk

It gives me this error though:

ld: warning: ignoring file /blahblah/BarcodeScannerNew/BarcodeScannerNew/zbar_iOS7_Fix/libzbar.a, missing required architecture i386 in file /blahblah/BarcodeScannerNew/BarcodeScannerNew/zbar_iOS7_Fix/libzbar.a (3 slices)

Undefined symbols for architecture i386:

  "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:

      objc-class-ref in AACsViewController.o

  "_ZBarReaderControllerResults", referenced from:

      -[AACsViewController imagePickerController:didFinishPickingMediaWithInfo:] in AACsViewController.o

ld: symbol(s) not found for architecture i386



clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think what that means is it wants the old (I presume 32 bit) libraries, not the latest ones. Not sure how to fix it though as I can't include both old and new Zbar files because it gives an error about duplicate files.

SOair
  • 173
  • 1
  • 3
  • 14
  • do you have a developer account and developing profile created for the app. – JIthin Aug 06 '14 at 08:47
  • What is the error? Probably you didn't set CodeSign identity for target. – Timur Kuchkarov Aug 06 '14 at 11:47
  • I do have a developer account. I don't have a profile for putting the app up to the app store, just testing which is all I'm interested in at the moment. @Timur there was no error - just a message saying build failed. – SOair Aug 07 '14 at 00:44
  • There definitely should be an error. You can see it in issues tab in navigation area(left pane), if it says something about codesign, you need to create development certificate and then select it(http://www.raywenderlich.com/8003/how-to-submit-your-app-to-apple-from-no-account-to-app-store-part-1 and also part 2 may help). Also for testing on device you need developer profile with either wildcard id( * ) or with defined bundle id. – Timur Kuchkarov Aug 07 '14 at 05:49
  • @Timur Thanks, it says something about a library not being included - see my edited post for the error log. – SOair Aug 07 '14 at 07:44
  • @Timur I want to add that the simulator doesn't work when trying the b 64 bit build either - I've added the log for that too. I think the causes may be linked. – SOair Aug 07 '14 at 07:51
  • You should rebuild the static lib "libzbar.a" with the same build setting of architecture. – KudoCC Aug 07 '14 at 08:42

2 Answers2

1

Doesn't look like ZBar is supported on iOS7. Last update was around iOS4 since when a lot has changed.

Source ZBar FAQ

gnuchu
  • 1,496
  • 13
  • 21
  • Ah, hm.. that changes things. I've looked for tutes for later frameworks to do barcode and qr code scanner with storyboards but never had any luck. Might just be what I put into google search though. Not sure. – SOair Aug 08 '14 at 01:44
  • Looks like it's part of core now. Have a look at http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx – gnuchu Aug 08 '14 at 07:45
  • My boss seems to be emphatic about using ZBar which actually got working recently using the old libraries but he wants me to use the latest - see my original post for an update. If I can't get it working using the latest however, I'll try that link you gave. Thanks for your replies! – SOair Aug 11 '14 at 01:12
0

Error says that zBar library isn't compiled for 64-bit simulators. So you'd either build library from sources with this support or wait for somebody to do it. Or just don't use 64-bit simulator for this. :)

This answer may help you to get this working on 64-bit simulator.

Also if you can support only iOS 7+, you can use system built-in code scanning capabilities.

Community
  • 1
  • 1
Timur Kuchkarov
  • 1,155
  • 7
  • 21
  • Thank you for letting me know. Could you give me a link to a built-in system code scanner tutorial? I've searched myself but I wasn't able to find something that someone new to Xcode could use to get it working with storyboard. – SOair Aug 08 '14 at 01:37
  • Seems I need to support iOS 6+ so I need something that works on both 6 and 7 – SOair Aug 08 '14 at 02:14
  • http://nshipster.com/ios7/ - this should help. AVCaptureMetaDataOutput section. Also comment below @gnuchu 's answer can help too. If you need to support iOS 6, you can use ZXing( https://github.com/TheLevelUp/ZXingObjC ). – Timur Kuchkarov Aug 08 '14 at 09:07
  • Thanks for your reply, that ZXing is what I'll look up if I can't fix my current issue with zbar (see my updated post). Boss wants to use Zbar with latest libraries so have to try that first now. – SOair Aug 11 '14 at 01:22