60°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • Compiling Spatialite for iOS

    May 21, 2015

    Since this took me a while to figure out, I figured I'd document it here in case it's useful to others later.

    First, install compiler dependencies. (If you don't already have Homebrew installed, you'll need to do that first.)

    brew install automake autoconf libtool libxml2 pkg-config
    brew link libxml2

    Build libspatialite from a very nice makefile that downloads and compiles libspatialite and its dependencies, SQLite, GEOS and PROJ.4.

    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: $(PROJECT_DIR)/AppName/libspatialite

    Header Search Paths: $(PROJECT_DIR)/AppName/libspatialite/include

    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!


    Thu, May 21, 2015 12:05pm -07:00
Posted in /articles using quill.p3k.io

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv