Sunday, July 10, 2011

Integrating with RedLaser SDK 3.0.0

If you've had the chance to try out the RedLaser app on your iPhone, then you know its usability is excellent and it is simply the best technology out there when it comes to scanning bar codes. As such, you may be rightfully tempted to download their SDK and try it out for yourself.

Now even though you'll find their out-of-box documentation in the 6MB-ish download to be enlightening, you may find yourself struggling and without any instructions when it comes to getting any project of you own up & running other than their RLSample project. I must say that the ZBar folks do a much better job of documenting similar integration items for their barcode scanning SDK. I just hope that the newly released RedLaser SDK 3.1.1 build1 will offer better docs than the Redlaser SDK 3.0.0 build21 that was used at the time of writing this blog entry.

Also you may feel dubious about purchasing the extremely expensive license without first figuring out if you have the skills to take your idea all the way. And you can't get into their forums without getting a license. So, I've put together some highlights to help you grapple with the SDK and get to a point where you can perform trial & error on your own to see if you have the right stuff :)
  1. Add files to "<your project>"...
  2. Navigate to wherever you downloaded and extracted the RedLaserDevSDK-3.0.0build21
    • The naming is not set in stone, it is spelled out here only to give you a feel for what you may be looking for on your mac.
  3. Drill-down into the RedLaserDevSDK-3.0.0build21/Sample/ folder and select the RedLaserSDK directory
    • Make sure to select the checkbox to Copy items into destination group's folder(if needed)
    • Also select the bullet option which will Create groups for any added folders
  4. Just to see if you can get anything simple to work on your own, you may try to run the build after pasting the barebones code from the Using the 3.0 RedLaser SDK.pdf file included with the SDK download.
    • Here's the code to throw into a method of your choosing:
      BarcodePickerController *picker = [[BarcodePickerController alloc] init];
      // Let's keep things simple by using the default built-in overlay
      //[picker setOverlay:customOverlay];
      [picker setDelegate:self];
      picker.orientation = UIImageOrientationUp;
      [[UIApplication sharedApplication] setStatusBarHidden:YES];
      [self presentModalViewController:picker animated:TRUE];
      [picker release];
    • Ofcourse you'll need to add #import "RedLaserSDK.h" at the top where you've pasted this code.
    • But the build still won't go through because some frameworks need to be added for the build to succeed.
  5. Goto <Your Project> > TARGETS > Build Phases > Link Binary With Libraries > +
    • libRedLaserSDK.a - XCode would have probably automatically placed this in the list when you imported the ./RedLaserDevSDK-3.0.0build21/Sample/RedLaserSDK directory.
    • CoreVideo.framework - makes sense since we need to the camera is used to perform the scans. If you started with something like 24 errors, adding this will bring them down to 18.
    • Security.framework - If you started with something like 18 errors, adding this will bring them down to 3.
    • libiconv.dylib - If you started with something like 3 errors, adding this will bring them down to 0.
  6. In addition you should add an empty implementation for what happens when a barcode is successfully read.
    • Here's the code:
      - (void) barcodePickerController:(BarcodePickerController*)picker
                         returnResults:(NSSet *)results
          [[UIApplication sharedApplication] setStatusBarHidden:NO];
          [self dismissModalViewControllerAnimated:TRUE];
  7. With this you can at least do a test build and run in the simulator mode which will not do much other than throw up the mock scanner screen from RedLaser.
  8. If you actually try to plug in your iPhone and directly test your app on the device you will run into a whole new slew of build errors! I received a total of 22 errors. Once again, goto <Your Project> > TARGETS > Build Phases > Link Binary With Libraries > +
    • libRedLaserSDK.a - XCode would have probably automatically placed this in the list when you imported the ./RedLaserDevSDK-3.0.0build21/Sample/RedLaserSDK directory.
    • AVFoundation.framework - If you started with something like 22 errors, adding this will bring them down to 6.
    • CoreMedia.framework - If you started with something like 6 errors, adding this will bring them down to 0.
  9. Now with a lot of luck and a little bit of elbow grease, when you connect your iPhone then build & run you app, you should see it launch and have the default RedLaser full-screen camera-view-like overlay being shown. All you will see is what you camera sees, no fancy buttons ... no nothing. But given that you never actually invoked any camera/media related functionality yourself, have faith in the fact that you've cleared the first phase in your experiments to integrate with RedLaser.
  10. Before beginning the 2nd phase, I had hoped to perform a simple experiment that would turn out as described below ... but that didn't happen so until I figure that out, this is it :(
    • Remembering that there are an extremely limited # of scans allowed w/ RedLaser SDK ... take the iPhone over to a barcode and try to scan it ... given the barebones code that we've talked through thus far, all that should happen is that the camera overlay screen will just disappear after a successful scan and you'll be left looking at an empty plane white view that had loaded this stuff to begin with.


  1. i get linker error for the red bar sdk even though i have added it crrectly

  2. I would like to help, could you perhaps provide some more details such as what linker errors you get exactly? Feel free to post them here, oremail them to me or discuss over chat or some other mode of communication and then I will fix my narration to account for those as well if need be :)

  3. Did you ever get the overlay to show up like they have in the example?

  4. Due to lack of open support and not having $10k+ to dish out ... I simply moved away from RedLaser SDK and started using ZBar SDK which has much better documentation and I got it to work there easily.