Xcode 12 issues

124 views
Skip to first unread message

Mark Hamilton

unread,
Nov 18, 2020, 11:09:49 PM11/18/20
to j2objc-discuss
Prior to the release of Xcode 12 we were successfully using j2objc to convert a java library to objective-c. However, since Xcode 12 came out we have been unable to get j2objc to run successfully. Is anyone else having issues since the 12.x release? Specifically it reports undefined_arch on a number of the java files. I have been trying to determine what this even mens, but have not been able to so far.

We have updated to j2objc 2.17 from 2.15 with no change. I have also "upgraded" to Xcode 12.2.

Additionally, in trying to troubleshoot this I have been trying to run the j2objc tool manually on the command line and have not been able to get the -sourcepath option to work. It only ever reports that no source files can be found. If I try to do one file at a time it will work until there are dependencies that need to be resolved from other sources.

At this point I am just trying to determine if others are having similar issues, and perhaps what the best way is to try and work through what I am seeing.

Thanks!

Mark Hamilton

Tom Ball

unread,
Nov 19, 2020, 12:51:52 PM11/19/20
to j2objc-discuss
What does "run successfully" mean? The major change in 2.6 (2.17 is waaay in the future ;-) is J2ObjC's frameworks became XCFrameworks, to support Mac Catalyst. If your build is failing because it can't find a J2ObjC framework, delete it from your project's Frameworks list (it should be red to show it wasn't found), then right-click Frameworks and add it again.

--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/j2objc-discuss/0527c057-af7b-4d71-b12b-d1327843d040n%40googlegroups.com.

Mark Hamilton

unread,
Nov 19, 2020, 3:33:07 PM11/19/20
to j2objc-discuss
Tom,

I apologize for not being more clear. We had been using the 2.5 version of j2objc and it has worked great. We recently had a number of changes that occurred all within the timeframe of a month and when I tried to build our library that uses j2objc it got errors and I have been trying to get all of that straightened out. I just inherited this process and have had no real idea how it worked.

After a couple of days of working with it and reading the website I am starting to better understand what is going on. The errors from my previous message were due to a java file not being in the correct location in its package hierarchy, preventing the dependency resolution from happening. Once that was fixed the transcoding has worked. I have update the j2objc to the 2.7 version and I think the JRE.xcframework is what I am now struggling with.

I am at the point where I am trying to compile everything. In the past there about 25 of the header files that are generated included in the bridging header file. Some of the old header files were no longer needed and some of the new ones needed to be added. After doing that I have reached a point where some of the swift files are now starting to be compiled. They ones that fail have an "import JRE" at the start and I get the error "Module 'JRE' not found". I have re-added the JRE.xcframework as you suggested with no change in the results. I have verified that the JRE.xcframework is included in the appropriate target, but any reference to a JRE module fails. I have not used used xcframworks before and am assuming that all frameworks inside an xcframework are referenced via the xcframeworks external name, in this case JRE and that the build selects the correct architecture.

I also noticed that the header files in the j2objc include directory appear to be the same as the headers included in the JRE.xcframework. I also assume if I can get the JRE.xcframework to work properly in my project that those will be available and I will not need to include the other directory as well. But that is less an issue than the .xcframework not being found.

Thank you so much for your help!

Mark

James Toddington

unread,
Nov 19, 2020, 4:28:10 PM11/19/20
to j2objc-...@googlegroups.com
Hi Mark, 

This may not be much use but it’s worth verifying that the correct ‘JRE.xcframework’ is referenced throughout all of your build files. 

I have encountered this in the past when updating to 2.7 but having a reference to the old framework name buried in the libs (or other setting section!) of an Xcode project or sub project dependency. 

Particularly if this is a project that you have inherited(!)

Cheers, 

Jim. 

Mark Hamilton

unread,
Nov 19, 2020, 4:55:56 PM11/19/20
to j2objc-discuss
Jim,

Thank you for the suggestion. I went through and rechecked that I only have the one JRE.xcframework in my project, and not an older JRE.framework (I just switched from the framework to the xcframework). However, your suggestion did make me wonder if there is more than one framework in the xcframework that can be referenced. Is that the case? If so how would I know which one to use?

Anyway, thanks for suggestion!

Mark

Tom Ball

unread,
Nov 19, 2020, 5:26:52 PM11/19/20
to j2objc-discuss
System test: please verify you can build the HelloSwift target in the j2objc-2.7/examples/HelloSwift/HelloSwift.xcodeproj Xcode project. It's a horrible app (we're not UI engineers), but demonstrates how to set up a simple Swift app that references a Java class. If that builds and runs, compare its settings with your project's.

An XCFramework should be treated as an opaque building block, even though you can peek inside it from the command line. It uses separate libraries for each support architecture/platform, but its Info.plist provides the information so that the application linker can pick which library it needs without specific configuration. Previously, Static Frameworks combined all libraries into a "fat-library" for distribution, but conflicts between platforms and CPU types grew as platform/CPU combinations expanded. For example, the MacOS, Mac Catalyst and iOS Simulator builds all target the x86_64 CPU, so they couldn't be in the same fat-library.

Although header files can be individually assessed if you hack your include paths, normally all of the framework's declarations are included with a single header that has the same name as the framework. For example:

#import "java/lang/System.h"
#import "javax/crypto/KeyAgreement.h"
#import "org/xml/sax/Parser.h"

can all be replaced with:

#import <JRE/JRE.h>

So there's normally no reason to look inside a framework or add build references to its internals, except when debugging a build failure.

Jim T

unread,
Nov 19, 2020, 5:31:10 PM11/19/20
to j2objc-discuss

I don’t know about that. I meant literally grep your pbxproj and Make files (depending on your build) to see if there is still a ref to the cleaned JRE.framework rather than the new JRE.xcframework. 

Mark Hamilton

unread,
Nov 19, 2020, 6:21:19 PM11/19/20
to j2objc-discuss
Jim,

That was it. There was a reference to the JRE.framework buried in a path. Once I knew where it was it was easy to update and and that solved the build issue. Interestingly, the path was to the headers dir in the framework. I changed it to ref the header dir dir in the xcframework and removed the include folder and now everything is building.

I think the next week is going to be spent on cleaning this up and documenting so whoever comes after me has some guidance.

Thanks!

Mark

Jim T

unread,
Nov 19, 2020, 6:26:20 PM11/19/20
to j2objc-discuss
No problem, Ha ha - It’s almost like we are working on the same project!

Jim. 

Mark Hamilton

unread,
Nov 19, 2020, 7:04:33 PM11/19/20
to j2objc-discuss
Tom,

Thanks for the response. Just to verify I did build the Hello and the HelloSwift examples and they both worked.

I think ultimately my lack of familiarity with j2objc and some poor practices in our project were the main cause of all of the issues. I will be spending time in the coming week doing some cleanup and documentation of our whole process.

Thanks for all your help and a truly remarkable tool!

Mark

Reply all
Reply to author
Forward
0 new messages