I have been searching up and down stackoverflow and Google for the correct way to compile and add the libtiff
library to my existing iOS project in Xcode.
What I have done so far:
EDIT:
I have downloaded libtiff to my Mac after deciding to follow this advice on stackoverflow. I used version 3.9.6 and built it like in this tutorial and its sequel about SDK5. There, in the comments, I found a script I could adapt. I have added the resulting "dependencies" folder to my Xcode project, almost like rakmoh suggested.
However, I got linker errors as soon as I #include tiffio.h
:
Undefined symbols for architecture armv7: "_inflateEnd", referenced from:
_PixarLogCleanup in libtiff.a(tif_pixarlog.o)
_ZIPSetupEncode in libtiff.a(tif_zip.o)
.
... some more...
.
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also tried the newest version of libtiff
, but that did not change a thing, so I went back to 3.9.6, as it is compatible with the other softwares in the project. Then I asked a colleague who found out it was the libz
library missing. From the log files he saw it must have been there during the compilation of libtiff
and it was still missing for the linker in my Xcode project. And lo! When I added it to the frameworks (with the little + sign and browse the list for libz.dylib
), my empty test project compiled.
Before writing an answer, I would like to do some more testing, but I have already updated the successful shell script to pastebin.
Thank you for your help!
I have pasted a bash script that cross-compiles
libtiff
version 3.9.6 on a Mac for iOS 6.1 to be used on devices and in the simulator. You will have to adapt it to your needs. Also see this tutorial for hints. It creates a fat library for both compilation targets.rakmohs answer is also correct, but only part of the solution. You add the folder with the fat library in the "Add Other.." dialogue he proposes.
Then you also add libz.dylib! After that, I could use
libtiff
in my app on my device and on the simulator.Here are the steps for adding a library to your iOS project in XCode 4.6.2 (should be similar in old versions of XCode):