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:
- Open objectiveflickr.xcodeproj in XCode
- Go to Project->Edit Project Settings and select the Build tab
- Change the Base SDK to iPhone Device 3.1.3
- Change the Architecture to ${ARCHS_STANDARD_32_64_BIT}
- Change the C/C++ compiler version to GCC 4.2
- Rebuild ObjectiveFlickr
- Return to your project
- 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.
[...] first post is Objective Flickr on the iPhone, inspired by some of the difficulties she had building her demo app for my Optical Character [...]
thank you for sharing your problem and solution. I have also hit this road block. With the help of your suggestions I got it compiling to Device->Debug BUT NOT Device->Release. I am such a newb with cocoa that I cannot offer any help. I posted to the github project and I hope the developer will fix the problem. I am working on ph.d in compsci but too new to xcode to help…i’m a dummy.
No worries about being a newb, I am too! I hadn’t tried to compile under release, I shall have a look and see if I can get it working. If I do, I’ll post an update here and let you know the answer!
I found this discussion on flickr forums http://www.flickr.com/groups/api/discuss/72157624352980394/#comment72157624656209058 His solution didn’t fix Device-Release. But it didn’t work for Device-Debug. Oh well, still looking for an answer. I am working on an iphone app that is almost complete. My partner has added his parts and is now waiting for me to finish flickr. This is extremely frustrating.
oops, meant to say it DID fix Device-Debug