google / j2objc

A Java to iOS Objective-C translation tool and runtime.
http://j2objc.org
Apache License 2.0
5.99k stars 968 forks source link

Headers information is missing from the XCFrameworks' "Info.plist" files #2180

Closed adil-hussain-84 closed 1 year ago

adil-hussain-84 commented 1 year ago

The XCFrameworks which are built right now place the Headers directory at the root-level of the XCFramework and omit mention of the headers in the XCFramework's Info.plist file.

We need to update the gen_xcframework.sh script so that it calls the xcodebuild -create-xcframework command with the -headers option as described in the Generate the XCFramework bundle Apple Developer guide. This will create a Headers directory and a HeadersPath entry in the Info.plist file for each architecture in the XCFramework.

I will create a Pull Request with this change shortly.

mungler commented 1 year ago

To be honest, I wondered about this when making the change documented in https://github.com/google/j2objc/pull/2175

I didn't make the change as our application seemed to work happily with the new XCFramework, but this definitely seems more 'correct'.

tomball commented 1 year ago

@mungler: please review @adil-hussain-84's PR #2181, since the two of you have become our domain experts on this topic. :-)

mungler commented 1 year ago

Haha, thanks @tomball will do that now

hohteri commented 1 year ago

Hey, was about to write to the discussions group but while you are at it, would you mind code signing the xcframework? Xcode 15 requires xcframeworks to be code signed. I just manually did that and had to delete Versions and Headers and copy Versions/A/Headers under each build variant and add HeaderPath to all AvailableLibraries in Info.plist. Basically what -headers option does.

I used the following command to code sign the xcframework: codesign --timestamp -s "Apple Development" ~/j2objc/dist/frameworks/JRE.xcframework

mungler commented 1 year ago

In fact, Xcode 15 does not require it to be codesigned, the problem is that the codesigning utility (/usr/bin/codesign) does not consider the package valid enough to even check the current code-signing status. If you delete Versions and move the headers as you say, Xcode will be happy, even without signing it. @tomball advised recently that he does not have an appropriate Google signing identity to sign the frameworks at this stage, so unsigned is the way to go.

My PR changed the structure of the XCFramework artefacts so that /usr/bin/codesign considers them valid, and the new one by @adil-hussain-84 corrects the structure to be in the format Apple specify.

In short - it it not necessary (and also not currently possible) to make a change to have the frameworks codesigned. You are free to codesign the artefacts yourself, but it doesn't really give you any benefit.

mungler commented 1 year ago

@tomball @adil-hussain-84 PR approved :)