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!
@smbkr, @Vaibhav-Narkhede, I forked the repo and started meddling with the Makefile to bring in the newest versions of the packages and add new dependencies as well. I will need to be able to incorporate spatialite in my app.
I feel like I should be on the right track, but I currently have an issue compiling the rttopo library that appears to be a dependency of the newest version of spatialite. My problem is that the build of the library fails at the configure stage because a check of the
geos_c
library for a specific symbol doesn't pass. This is the relevant snippet:I checked the built library archive file using
nm build/armv7/lib/libgeos_c.a
and did find the symbol there. I am also passinggeos-config
from thebin
directory inbuild/armv7
to make sure the right one is picked. I am kind of suspecting that it's maybe picking up thelibgeos_c
library I have in my system in/usr/local/lib
because I have PostgreSQL with PostGIS installed as well, but I am not entirely sure about this.I have my fork here so if any one of you guys want to take a look and maybe give a hint, I'd be grateful. 😊