0

I'm trying to convert a java library to objective-c using j2objc and include the generated objc files into my XCode project. I managed to generate the objc files, but XCode gives me the following error: https://i.stack.imgur.com/QX3zF.png

I used lipo -info on a .o file and I get this "architecture: x86_64". Does it mean those objc files are not meant to run on arm64 architectures and if so, how can I solve this ? Are there any flags I could use to generate the files for arm64 ?

A previous error I had was "ARC forbids explicit message" and I solved this by adding a compiler flag -fno-objc-arc to all the compile sources related to this error. Is this solution safe ?

  • Hi Viorel, glad to see your first question on stackoverflow. I'll suggest to include the trace in the question itself for people to look at right here on SO instead of external image link. It'll surely increase your chances to get an answer quickly. While including trace, please use SO formatting options to keep it plain text, makes it much more readable. A good laid out question attracts good answers on SO. All the best! – Avnish Feb 03 '20 at 16:47

1 Answers1

0

To compile for arm64, the -arch arm64 and -isysroot IPHONE_SDK_DIRECTORY flags are needed. To find the IPHONE_SDK_DIRECTORY on your system, run xcrun -sdk iphoneos --show-sdk-path.

There's nothing J2ObjC-specific about this, they are normal iOS flags you'll find in you look at the log of a successful compile of an Objective C file in Xcode and click its right button to expand and show all the flags used.

J2ObjC by default does not generate ARC code, so the -fno-objc-arc flag is okay. If you would prefer ARC, run j2objc with its -use-arc flag. Don't compile those generated files with -fno-objc-arc, however, as objects won't be released when your app is finished with them.

tball
  • 1,984
  • 11
  • 21
  • So XCode compiles my .m files using its own gcc and then the .o files are generated, right ? I know that I can compile those files in a terminal window using this command (and I can use those arch flags here): j2objcc -c -I. $(find -name *.m) But how can I add these flags in XCode ? – Viorel Onica Feb 04 '20 at 12:06
  • when I removed -fno-objc-arc from compile flag I got the Darwin cycle error how can use it without error tball? – Amir Ardalan May 04 '21 at 10:41
  • You'll have to ask someone who works on Xcode or clang, the C compiler Apple distributes with Xcode. As I said in the accepted answer, "There's nothing J2ObjC-specific about this, they are normal iOS flags you'll find if you look at the log of a successful compile of an Objective C file in Xcode". – tball May 05 '21 at 16:24