Code Monkey home page Code Monkey logo

libspatialite-ios's Introduction

libspatialite-ios

A Makefile for automatically downloading and compiling libspatialite (including its dependencies SQLite, GEOS and PROJ.4) statically for iOS.

The resulting library is a "fat" library suitable for multiple architectures. This includes:

  • armv7 (iOS)
  • armv7s (iOS)
  • arm64 (iOS)
  • i386 (iOS Simulator)
  • x86_64 (iOS Simulator)

Requirements

Xcode 12.1 with Command Line Tools installed. The following compiled dependencies can be installed with Homebrew:

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

Installation

Simply run

make

Usage

  • Copy the contents of lib and the include directory to your Xcode project directory. You should end up with something like the following:
lib/
└── libspatialite
    ├── include
    │   ├── geodesic.h
    │   ├── geos
    │   │   ├── (many more files in geos)
    │   ├── geos.h
    │   ├── geos_c.h
    │   ├── org_proj4_PJ.h
    │   ├── org_proj4_Projections.h
    │   ├── proj_api.h
    │   ├── projects.h
    │   ├── spatialite
    │   └── spatialite.h
    ├── libgeos.a
    ├── libgeos_c.a
    ├── libproj.a
    ├── libspatialite.a
    └── mod_spatialite.a
  • Then, drag the contents from Finder into the project navigator to incldue them in your project. Xcode should automatically add the library files to the "Build Phases" window. If not, add them later when you add the other required libraries.

  • Add these to the search paths in your Xcode project's "Build Settings":

    • Library Search Paths: $(PROJECT_DIR)/AppName/lib/libspatialite
    • Header Search Paths: $(PROJECT_DIR)/AppName/lib/libspatialite/include
  • And in the "Build Phases" window, add the following to the section "Link Binary With Libraries":

    • libiconv
    • libcharset.1.0.0
    • libc++
    • libxml2.2
    • libz
  • Lastly, if your project is written in Swift, include the headers in your bridging header:

//
//  bridging.h
//

#include <sqlite3.h>
#include <spatialite/gaiageo.h>
#include <spatialite.h>
  • Now you should be able to use Spatialite:
spatialite_init(0);
print(spatialite_version()!)

Acknowledgements

Thanks to gstf for providing the original repository this is forked from (https://github.com/gstf/libspatialite-ios), as well as davenquinn and smellman for their forks making it possible to build for newer versions. Thanks to aaronpk for the instructions on how to use this in an iOS project (https://gist.github.com/aaronpk/0252426d5161bc9650d8). This is heavily adapted from all of their work.

libspatialite-ios's People

Contributors

muellermartin avatar davenquinn avatar gstf avatar mbcharbonneau avatar adolby avatar hallahan avatar smbkr avatar smellman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.