Is it possible to use a version higher than 1.0-SNAPSHOT on iOS?

Hello,
is graphhopper version 1.0-SNAPSHOT the latest available for an iOS project?
Or is it possible to use a 5.x version?

Following the official guide (graphhopper-ios from graphhopper - GithubHelp) he automatically downloaded the latest ios_compatibility version of graphhopper (1.0-SNAPSHOT).

The project I’m working on includes two mobile apps, one iOS and one Android.
IOS side I should align with the 5.0-pre1 version used on Android.
It’s possible?

Thank you

Hi @Emanuele can you give us more information about your problem? Update your question with more detail about the errors mets during the procedure

Thanks

Having to use version 5.0-pre1, I downloaded the zip of the project from git and extracted its contents in the graphhopper-ios/graphhopper/ folder.

Running the “make class.list” command I encountered the following error:
“find: graphhoper/api/src/main/java: No such file or directory”

In version 5.0-pre1 some fundamental folders are missing such as the graphhopper/api/ folder.

At first I copied the “api” folder and the “Android” folder from version 1.0 and successfully ran the make commands.
Inside “build” generated the *.a files but the “translations” folder is empty.
Trying to launch the “graphhopper-ios-sample” app I realized that other elements are also missing.
For example in src/com/ the graphhopper folder with all the iOS classes is missing.
Some libraries are also missing: libicucore.dylib - libsqlite3.dylib - libz.dylib.

The files that are missing probably weren’t removed between 1.0 and 5.0-pre1, but rather they were renamed or moved. For example everything graphhopper/api/... should be now in graphhopper/web-api/. This change in particular is also mentioned here: graphhopper/CHANGELOG.md at master · graphhopper/graphhopper · GitHub, but not all such changes will be listed.

In prepare.mk and in makefile I changed the pointing from api to web-api and at the make command I got these errors:

(since there are so many I just put a few and attach the complete log error.txt)

graphhopper/web-api/src/main/java/com/graphhopper/jackson/MultiExceptionSerializer.java:20: error: package com.fasterxml.jackson.core does not exist
import com.fasterxml.jackson.core.JsonGenerator;
.
graphhopper/core/src/main/java/com/graphhopper/reader/osm/pbf/PbfFieldDecoder.java:4: error: package org.openstreetmap.osmosis.osmbinary does not exist
.
.
graphhopper/core/src/main/java/com/graphhopper/reader/osm/OSMXMLHelper.java:26: error: package javax.xml.stream does not exist
import javax.xml.stream.XMLStreamConstants;
.
.
graphhopper/core/src/main/java/com/graphhopper/routing/lm/LMPreparationHandler.java:20: error: package com.bedatadriven.jackson.datatype.jts does not exist
import com.bedatadriven.jackson.datatype.jts.JtsModule;
.
.
graphhopper/core/src/main/java/com/graphhopper/reader/osm/WaySegmentParser.java:36: error: package javax.xml.stream does not exist
import javax.xml.stream.XMLStreamException;
*
graphhopper/core/src/main/java/com/graphhopper/reader/osm/OSMInput.java:22: error: package javax.xml.stream does not exist
import javax.xml.stream.XMLStreamException;
.
.
graphhopper/core/src/main/java/com/graphhopper/reader/osm/OSMFileHeader.java:22: error: package javax.xml.stream does not exist
import javax.xml.stream.XMLStreamConstants;
.
.
graphhopper/core/src/main/java/com/graphhopper/reader/osm/pbf/PbfStreamSplitter.java:4: error: package org.openstreetmap.osmosis.osmbinary does not exist
import org.openstreetmap.osmosis.osmbinary.Fileformat;
.
.
graphhopper/core/src/main/java/com/graphhopper/routing/weighting/custom/CustomModelParser.java:394: error: cannot find symbol

  • private static SimpleCompiler createCompiler(long counter, Java.AbstractCompilationUnit cu) throws CompileException*

At this point I copied osmosis in the dependences folder and added the path in makefile but it threw this exception (in error_2.txt there is the complete log):

Exception in thread “main” java.lang.AssertionError: annotation tree hasn’t been attributed yet: @SuppressWarnings(“deprecation”)

error_2.txt (4.0 KB)

error.txt (33.1 KB)

This is and all the other errors regarding Jackson occur because GraphHopper core now depends on the Jackson library, also see here, which you probably also have to add to the dependencies.

This one is probably due to the Janino dependency that was added here.

I don’t know what this is.

I did a last test using the “Maven plugin for J2ObjC library” but it always fails.

Executing the command mvn j2objc:convert -X, it always returns the exception:
Exception in thread “main” java.lang.AssertionError: annotation tree hasn’t been attributed yet: @SuppressWarnings(“deprecation”)

and cannot find the jar file:
/.m2/repository/com/graphhopper/graphhopper-web-api/5.0-SNAPSHOT/graphhopper-web-api-5.0-SNAPSHOT-sources.jar (No such file or directory)

But in the folder I have a graphhopper-web-api-5.0-SNAPSHOT.jar

I attach the pom with the configurations and the log with the complete error.

Do you have any ideas?
Thank you
log.txt (15.3 KB)
pom.txt (4.5 KB)

/.m2/repository/com/graphhopper/graphhopper-web-api/5.0-SNAPSHOT/graphhopper-web-api-5.0-SNAPSHOT-sources.jar

But in the folder I have a graphhopper-web-api-5.0-SNAPSHOT.jar

Note that the one that is missing seems to be the graphhopper-web-api-5.0-SNAPSHOT-sources.jar, not the graphhopper-web-api-5.0-SNAPSHOT.jar. The sources jar is created by the source plugin: Apache Maven Source Plugin – Usage

The source plugin needs to be configured in the pom.xml file. For example for GraphHopper 5.3 it is only enabled when the ‘release’ profile is used: graphhopper/pom.xml at af5ac0b0ae024da4b23966b1eef480508b5eedbb · graphhopper/graphhopper · GitHub, maybe you need to add something in this direction to your pom.xml file as well.

Ok, I added the required dependencies (graphhopper-web-api-5.0-SNAPSHOT-sources.jar, hppc-0.8.1-sources.jar, janino-3.1.2-sources.jar, jts-core-1.15.1- sources.jar, jackson-core-2.10.5-sources.jar and jackson-databind-2.10.5.1-sources.jar) and a few steps forward I have done that.

But when I add jackson-core (version 2.10.5) it crashes with this error:
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for com.fasterxml.jackson.core: jackson-core: jar: sources: 2.10.5

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.fasterxml.jackson: jackson-base: pom: 2.10.5

Ok, I added the required dependencies

Can you use the Jackson source code directly from their repo? GitHub - FasterXML/jackson-core: Core part of Jackson that defines Streaming API as well as basic shared abstractions I was able to compile it using the branch 2.10: GitHub - FasterXML/jackson-core at 2.10

This one is probably due to the Janino dependency that was added here.

Please note that all custom model related functionality can only be created at the Java side and then used on the iOS side. I don’t think it is possible to run janino on iOS and so this dependency should be mocked away on iOS somehow.

Thanks for the previous answers, I continued with the tests and now running the command mvn j2objc: convert I get this error:

/Users/pamela/Documents/GraphopperPorting/src/main/java/com/graphhopper/reader/osm/OSMInput.java:22: error: package javax.xml.stream does not exist
[ERROR] import javax.xml.stream.XMLStreamException;
[ERROR] ^
[ERROR] /Users/pamela/Documents/GraphopperPorting/src/main/java/com/graphhopper/reader/osm/OSMInput.java:25: error: cannot find symbol
[ERROR] ReaderElement getNext() throws XMLStreamException;
[ERROR] ^
[ERROR] symbol: class XMLStreamException
[ERROR] location: interface com.graphhopper.reader.osm.OSMInput
[ERROR] /Users/pamela/Documents/GraphopperPorting/src/main/java/com/graphhopper/reader/osm/OSMXMLHelper.java:26: error: package javax.xml.stream does not exist
[ERROR] import javax.xml.stream.XMLStreamConstants;
[ERROR] ^
[ERROR] /Users/pamela/Documents/GraphopperPorting/src/main/java/com/graphhopper/reader/osm/OSMXMLHelper.java:27: error: package javax.xml.stream does not exist
[ERROR] import javax.xml.stream.XMLStreamException;

Do I need to add any other dependecies? I attach the pom file with the list of dependencies used.
pom.txt (4.6 KB)

This looks like you are missing the jaxb dependency. jaxb used to be part of the JDK until version 8, but was removed for JDK 11 and higher. You should be able to figure out which maven dependencies you need exactly by searching for these error messages as this is a common problem.

@Emanuele As the import is not done or not necessary on the mobile device you could also ignore the classes around OSMReader, probably even the entire reader/osm package?

This was ignored before but maybe due to our refactoring it is no longer ignored?

Maybe this is also related to the fact that the reader-osm Maven module was moved into the core module between GH 2.0 and 3.0

Good morning,

i tried to do Graphhopper conversion via j2objc plugin with command:

mvn j2objc: convert

The execution of the command highlighted the lack of two libraries and it was necessary to insert the following dependencies in the pom:

<dependency>
	<groupId>com.jtransc</groupId>
	<artifactId>jtransc-rt</artifactId>
	<version>0.5.0-ALPHA4</version>
</dependency>
<dependency>
	<groupId>javax.xml.stream</groupId>
	<artifactId>stax-api</artifactId>
	<version>1.0-2</version>
</dependency>

Adding the dependencies, the conversion highlighted a problem related to the jts-core library where the lack of the java.awt library was reported.
Reading the logs, I noticed that the problem was not directly linked to the source project, but to the dependency within the j2objc-maven-plugin plugin, so momentarily, as a workaround, it was commented and I managed to get to the end of the processing.
The conversion then created a folder in target called j2objc which contains all the project’s java classes translated into .h and .m, all at the same level without package differentiation.

At this point what are the steps to try to rebuild everything by getting the library compiled?

Unfortunately I only know the rough procedure: you use j2objc to get ObjectiveC code from java code and then you compile them via make? The final step would be to create a graph using the script at graphhopper-ios-sample/import-sample.sh (which needs an update, see here)

Maybe you can also create a pull request with your efforts and ping the previous contributors like OlKir (Update iOS example to use graphhopper 1.0 by OlKir · Pull Request #51 · graphhopper/graphhopper-ios · GitHub) or oflebbe (Changes for modern ios and GraphHopper 1.0 by oflebbe · Pull Request #47 · graphhopper/graphhopper-ios · GitHub)

the conversion highlighted a problem related to the jts-core library where the lack of the java.awt library was reported

This sounds strange as there shouldn’t be such a dependency. Maybe you did not exclude the tools module of graphhopper?

Hello,
I went ahead from Emanuele’s scenario and converted the graphhopper library by producing the .h and .m files, modifying some part of the code, without however including the jts library among the imports of the j2objc-maven-plugin plugin beacause it requires java.awt library which does not you can import.
At this point I have created a new Static Library Project in xCode to import these files, but during the building it does not find the includes “Geometry.h” and “Point.h” which are part of the jts library.
How can I fix this and go ahead with creating the library for iOS?

Thank you very much.

Matteo

Are you sure? We also had this JTS dependency in version 1.0 and at that time it was possible to create the JTS library from sources according to this PR: Update iOS example to use graphhopper 1.0 by OlKir · Pull Request #51 · graphhopper/graphhopper-ios · GitHub

Hello,

yes, I’m sure. Converting graphhopper 5 and including the jst library in j2objc plugin:

org.locationtech.jts jts-core 1.15.1

I receive those errors:

[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:14: error: package java.awt does not exist
[ERROR] import java.awt.Shape;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:15: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.GeneralPath;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:16: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Point2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointTransformation.java:14: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Point2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:14: error: package java.awt does not exist
[ERROR] import java.awt.Shape;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:15: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Ellipse2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:16: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.GeneralPath;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:17: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Line2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:18: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Point2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PointShapeFactory.java:19: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.Rectangle2D;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:71: error: cannot find symbol
[ERROR] private Point2D transPoint = new Point2D.Double();
[ERROR] ^
[ERROR] symbol: class Point2D
[ERROR] location: class org.locationtech.jts.awt.ShapeWriter
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:168: error: cannot find symbol
[ERROR] public Shape toShape(Geometry geometry)
[ERROR] ^
[ERROR] symbol: class Shape
[ERROR] location: class org.locationtech.jts.awt.ShapeWriter
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/ShapeWriter.java:181: error: cannot find symbol
[ERROR] private Shape toShape(Polygon p)
[ERROR] ^
[ERROR] symbol: class Shape
[ERROR] location: class org.locationtech.jts.awt.ShapeWriter
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PolygonShape.java:14: error: package java.awt does not exist
[ERROR] import java.awt.Rectangle;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PolygonShape.java:15: error: package java.awt does not exist
[ERROR] import java.awt.Shape;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PolygonShape.java:16: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.AffineTransform;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PolygonShape.java:17: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.GeneralPath;
[ERROR] ^
[ERROR] /Users/mdebonis/Documents/Graphopper/GraphopperPorting/target/classes/jts-core/org/locationtech/jts/awt/PolygonShape.java:18: error: package java.awt.geom does not exist
[ERROR] import java.awt.geom.PathIterator;
[ERROR] ^

The makefile uses the jts under the folder dependencies and there is a file class-exclude.grep that seems to just ignore these classes. See at the end.