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?
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.
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”)
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 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)
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
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
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.
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?
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)
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?
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.