graphhopper / graphhopper-ios

iOS Port of the GraphHopper road routing engine
https://www.graphhopper.com/open-source/
Apache License 2.0
69 stars 28 forks source link
graphhopper ios navigation

graphhopper-ios

graphhopper-ios wraps graphhopper and creates the libgraphhopper.a library to be used on iOS. Theoretically it should be possible to include other architectures, but for example MacOS currently doesn't work.

It uses j2objc to translate the .java sources into Objective-C.

Disclaimer: This is experimental so treat it accordingly. Feel free to help in any way.

Prerequistes

JDK 8 (Yes, jts source needs JDK 8), recommended is AdoptOpenJDK8 Maven XCode 11.4+ (works with XCode 13)

Getting Started

To get started run the following commands in Terminal:

git clone https://github.com/graphhopper/graphhopper-ios.git
cd graphhopper-ios
git submodule init
git submodule update
make cleanall
make class.list
make translate
make
./graphhopper-ios-sample/import-sample.sh
open graphhopper-ios-sample/graphhopper-ios-sample.xcodeproj

Switch scheme to graphhoppper-ios-sample and run against Simulator or the real device (requires Apple Developer account and signing setup in place).

To integrate GraphHopper in your project see Usage section below.

Community

Feel free to raise problems or questions in our forum.

Usage

Xcode

To configure your project to use graphhopper.xcodeproj follow the steps below:

You're now ready to use GraphHopper on iOS and OS X.

You are responsible for importing graph data. For an example check out graphhopper-ios-sample.

Terminal

Alternatively, you can translate and compile the library by invoking make in the Terminal. You can modify common.mk and library.mk to include all necessary arhitectures. This article provides good overview of options: https://docs.elementscompiler.com/Platforms/Cocoa/CpuArchitectures/ Then link the library graphhopper-ios/build/libgraphhopper.a and it's header files at graphhopper-ios/src manually into your project. For all the other configurations see the Xcode section above.

By default this method compiles the library for the following architectures: simulator, iphoneos.

Example

iPhone-offline-routing

Requirements

Troubleshooting

If you run into problems, you can try one of the following:

Refresh Code

The dependencies j2objc, hppc and jts should be downloaded automatically if not present. You can force to reload by removing them:

make dependencies/hppc dependencies/jts j2objc