No able to build J2ObjC

456 Views Asked by At

I have fulfilled the requirements for installing j2objc on my mac as follows:

Apple macOC Catalina Version 10.15.7
Xcode Version 12.2 (12B45b)
JDK 1.8 installed - JAVA_HOME=`/usr/libexec/java_home -v 1.8`
JDK 11 installed
/Users/userName/Downloads/apache-maven-3.6.3" installed
Xcode command line tools installed
J2OBJC_HOME=/Users/userName/J2objc
J2ObjC project successfully cloned
libprotoc 3.14.0 installed

In the terminal I cd to j2objc directory and run make dist. This process appears to be never-ending, in fact, I have noticed the compile command is duplicated many times. I let it run for nearly an hour but it never comes to an end. Equally, when running other make commands the result is the same.

I have tried compiling a text java object with the following command:

$ j2objc javaTest.java
and this results in the following error message:
Exception in thread "main" com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath

I have also tried to open and run the HelloSwift app in Xcode but although it compiles successfully the Simulator does not start. I did specify the J2OBJC_ARCHS as specified in the instructions.

I guess I am missing something or have not understood the instructions. Any help would be much appreciated.

1

There are 1 best solutions below

5
On

A full build of j2objc can easily take more than an hour, because both the Java Runtime Environement (JRE) and Guava libraries are very large. Its build looks to be repeating itself because each translated source file needs to be separately compiled for a specific architecture, which currently is eleven for every combination of Apple hardware and CPU type.

The make command runs commands sequentially, but since all Mac systems have processors with multiple cores, the build is much faster when the -j flag is used to specify how many concurrent build tasks to use. My Macbook Pro has six cores, so running the build with make -j6 will build it in almost one-sixth the time.

The next biggest build speed improvement is to specify a subset of J2OBJC_ARCHS as you mentioned; the setting in my ~/.bashrc is export J2OBJC_ARCHS="macosx simulator64" (if you normally develop to an iOS device, add its arch to that list). The list of archs j2objc builds is created here, with macosx64 (macOS ARM) added after the last j2objc release.