Reputation: 113
I have an iOS app updated to the latest SDK8.3 and I am using the latest version of Xcode. My app uses libtiff to convert an image (in PNG format) to TIFF format. The problem I have is that I need to submit a new revision to the App Store and needs to incorporate 64 bit architecture. The libtiff library in my project is old and I have to update to the latest version.
I have downloaded libtiff 4.0.3 from the official download site ( ftp.remotesensing.org) but I can't build it for the needed architectures, I get an error. I have read this post but is is a little outdated and I presume Apple changed the toolchain in Xcode 6 compared to Xcode 5 or Xcode 4.
I am not an expert in the gcc / llvm toolchain and I am a bit lost here. I just need the tiff library in my Xcode project and successfully compile it. I've tried to build the library myself but it builds just for OS X and I need iOS.
Documentation about TIFF in iOS is scarce and I would prefer to use PNG, but for business reasons I need to use TIFF. Has anyone successfully compiled libtiff into a fat binary to include the 5 required architectures (i386, x86_64, arm64, armv7, armv7s)?
I only need tiff conversion but without jpg compression, so I am guessing I do not need the jpeg library.
Upvotes: 4
Views: 1407
Reputation: 2309
I had similar problems but fortunately I found this Github project. Just follow the instructions and build the libraries. Build libjpg first because is a dependency of liftiff.
Use terminal and go to the folder of the downloaded project, in my case is liftiff-ios-master
, and run these two scripts, and in this order.
./build-jpg.sh
./build-tiff.sh
Once finished in the liftiff-ios-master/dependencies
folder you will find two folders, include
and lib
with all the necessary files.
In Xcode just copy the following files to your project (these are just the necessary files for libtiff
, no need to copy the jpeg library files unless you need jpeg compression support):
and verify that liftiff.a
was added to your Link Binary With Libraries
section of the Build Phases
tab in your target.
In your .h or .m file just include this:
#import <tiffio.h>
Compile and run. Make sure the setting Architectures
of your Build Settings
is set to Standard architectures (armv7, arm64)
To verify that liftiff.a
has all the desired architectures, within its folder and from the terminal use:
$ file libtiff.a
libtiff.a: Mach-O universal binary with 5 architectures
libtiff.a (for architecture armv7): current ar archive random library
libtiff.a (for architecture armv7s): current ar archive random library
libtiff.a (for architecture i386): current ar archive random library
libtiff.a (for architecture x86_64): current ar archive random library
libtiff.a (for architecture arm64): current ar archive random library
Upvotes: 3