Home > Development, Mobile Dev > Objective Flickr on the iPhone

Objective Flickr on the iPhone

I have been working towards building my very first iphone app, and one of the challenges was to upload some images to Flickr. After much failure to create the signature that the Flickr API requires to authorise requests that flickr would accept, I was pointed towards ObjectiveFlickr, an Objective C library designed to ease the pain of working with the Flickr API.  This is a fantastic tool and has saved me endless headaches, however getting the library to work when in Device mode in XCode is a right pain in the butt. In order to ease any development pains that others might experience when using this library, I will now detail what I did in order to get everything to work.

After downloading the Objective Flickr library from github, I followed the instructions for adding the library to an iphone project as detailed in the documentation. I was most distressed when, after following the install instructions word for word, my app would not build. To check I was doing things correctly, I created a new project just to play around and test ObjectiveFlickr. Here the project built just fine and I could use the libraries with no problems. I went back to my original project, removed ObjectiveFlickr and reinstalled. Again, compilation errors.

"No architectures to compile for (ARCHS=x86_64, VALID_ARCHS=i386)."

As an iphone newbie, the compilation error did not immediately raise any warning flags so I hit our old friend google and tried to find out more about it.  After a bit of digging I found that this was actually the only bug raised against ObjectiveFlickr in the github project.  This is a problem that only raises it’s ugly head using ObjectiveFlickr when building against the device. The reason my test project worked was that it was building against the simulator. If I changed my target to the simulator then the project compiled. However I was using the camera in my app, which does not work in the simulator, so I needed it to work against the device.  The workaround from the ObjectiveFlickr site was this:

Build the objectiveflickr.xcodeproj project with changed settings "Architectures : Standard(32-bit Universal)" and then rebuild the project using objectiveflicr.

Turns out it’s not quite as simple as all that, so here was what I had to do, step by step, to get ObjectiveFlickr working in XCode building against the iphone device 3.1.3:

  1. Open objectiveflickr.xcodeproj in XCode
  2. Go to Project->Edit Project Settings and select the Build tab
  3. Change the Base SDK to iPhone Device 3.1.3
  4. Change the Architecture to ${ARCHS_STANDARD_32_64_BIT}
  5. Change the C/C++ compiler version to GCC 4.2
  6. Rebuild ObjectiveFlickr
  7. Return to your project
  8. Rebuild you project (probably best to Clean All Targets first, just to be on the safe side)

If ObjectiveFlickr does not compile after setting the Base SDK to iPhone Device 3.1.3, return the Base SDK  to Current Mac OS. Changing the compiler version from the LLVM compiler to the GCC compiler was neccessary because once I had recompiled objective flickr against the iphone libraries, when I then recompiled my project it complained that the LLVM compiler was not available.

error: can't exec '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2' (No such file or directory)

Turns out that for iPhone SDK’s 3.1.3 and below at least, the LLVM compiler is not available on the device. It’s available for simulator though, which is annoying to say the least.

This has highlighted to me one very annoying thing that I was not aware of before. Things that compile, build and deploy successfully on the simulator, may not compile build and deploy successfully on the device. Why Apple have not created the simulator to exactly simulate behaviour on the device is beyond me, but now I am aware of it I shall be careful not the be caught out like this again.