I want to use j2objc with an external build rule with Xcode, described to some extent here: https://developers.google.com/j2objc/guides/external-build-projects
What I have accomplished so far:
- Transpile the java sources using a makefile
- Create an external build project as described in the above mentioned link
- Add this build project to my specific project in which I want to use the transpiled sources
- When I build this project the transpiled Java/Objective-C sources can be found in the build directory
- Importing the transpiled sources in my bridging header (I'll use Swift instead of native Objective-C)
What doesn't work:
- Calling the classes/methods from my app, since the linking of the transpiled/compiled Java sources (the object files) with my applications object files does not function properly.
So in essence: the build directory has the needed object files (compiled from the Java sources) but since these are not linked correctly any call to these methods will result in a failing build.
Can someone provide a step by step guide on how to add an external build project (the one providing the object files through a makefile) to an Xcode project and link the object files?
Edit:
How I added the external build project:
Through "Add Framework" under Target->General->Frameworks, Libraries and Embedded Content. And then adding this again under Target->Build Phases->Target Dependencies
Edit 2:
After tball suggested looking into the jre_emul project I am now confident, that I don't know that much about the compiling process as I'd like to. :-/
I got it going, but in a way which does not really seem as the supposed way:
- I had to add the compiled *.o file as a resource to the project, so that I could add it to the Target->Build Phases->Link Library with Binary section (that's awful I think, since the object file is only created after the first build into a build directory with an arbitrary name. adding this to the project as resource sabotages any attempt at source controlling the project.
- Adding $(TARGET_TEMP_DIR) to the header search paths had no effect whatsoever unfortunately
- I added the $(J2OBJC_DIST)/include in the user header search and library search path
- I had to add the $(J2OBJC_DIST)/lib/macosx path to the library search paths, since only adding /lib recursively would end up in an error saying that the /lib/appletvos/libjre_emul.a is not compatible (that would be kind of ok, since I can set different library search paths for the different targets
- after adding -ljre_emul and -liconv to the other linker flags the build finally was successful.
So it would work this way, but I can't imagine that this is the right way.