Install compiler dependencies
brew install automake autoconf libtool libxml2 pkg-config
brew link libxml2
Build libspatialite
git clone https://github.com/gstf/libspatialite-ios.git
cd libspatialite-ios
make
The result is a folder, lib, containing several .a
files, as well as an include
folder containing many .h
files.
Create a new XCode project
Copy the libspatialite binaries and "include" folder into a folder named "libspatialite" in the XCode project folder.
In the XCode project's "Build Settings", you'll need to set the library and header search paths:
Library Search Paths:
Drag the .a
files into your project.
From the "Build Phases" window, add the following to the section "Link Binary With Libraries":
- libz.dylib
- libxml2.2.dylib
- libc++.dylib
- libcharset.1.0.0.dylib
- libiconv.dylib
Now you should be able to use spatialite! To test if everything worked, just make your AppDelegate output the spatialite version.
Add the following to AppDelegate.m
#include <sqlite3.h>
#include <spatialite/gaiageo.h>
#include <spatialite.h>
In your application:didFinishLaunchingWithOptions:
method, add:
spatialite_init (0);
printf("Spatialite version: %s\n", spatialite_version());
Compile and run and you should see the version output in the console!
Just to follow up on my previous message, I was able to make it all work eventually. I found out
librttopo
(as well aslibtiff
) were optional so I set configure scripts to stop looking for them, but had to add customlibsqlite3.a
build step (for which there already were targets, but were not used) because the default sqlite3 headers in Xcode did not seem to provide functions for loading extensions.I am not very familiar with all this on Mac OS (been using Linux for the last 15 years, though), so I hope I got it right. At any rate, I am going to include the output of the build in my project and see how that goes. I also updated my fork with the new changes so feel free to check them out.