New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ios): ignore the mac build if it failed and exclude sim arm64 if thirdparty .framework is there #12093
Conversation
Tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestions aren't required, but I think would clean the code up a little/make it simpler.
iphone/cli/commands/_buildModule.js
Outdated
// Assumption is that simulator arm64 architecture can only be supported via .xcframework. | ||
const frameworkPattern = /([^/]+)\.framework$/; | ||
let frameworksPath = path.join(this.projectDir, 'platform'); | ||
let legacyFrameworks = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, use const
@@ -447,7 +447,14 @@ iOSModuleBuilder.prototype.buildModule = function buildModule(next) { | |||
this.logger.error('[' + type + '] ' + line); | |||
}, this); | |||
this.logger.log(); | |||
process.exit(1); | |||
if (type === 'xcode-macos') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this should be handled by the caller (code at bottom of the file that launches these xcodebuilds). I'm fine with the change here since that code would get messy if we just bubbled up the exit code and had to do error handling there as it stands. But I think long-term we should move towards async/await in place of callbacks and do the handling there (so just bubble up the code as return value here, don't call process.exit here, etc and then it's a matter of try/catch down there)
As per @hansemannn 's comments in the linked ticket, we may just want to use the Xcode build setting as the "flag" to determine if the module is intended to target macOS. We've basically been forcing Or are we worried that module developers just won't toggle it on, even though it may literally require no other work for them to get macOS support included? Perhaps some combination of the above and checking the flag - i.e. try to build for macOS, and bubble up an error/build failure if they have the flag on , treat it as a "warning" and continue if they don't have it on? cc @janvennemann |
all = do not build for particular target . Or will it be more complex ? cc @sgtcoolguy @janvennemann . |
Maybe just a |
@vijaysingh-axway I tried your update and it still doesn't work:
Did you try with Ti.WidgetKit? |
Just using the setting from the Xcode project would be ideal of course. But as Vijay already pointed out this is not possible in ObjC modules since the project is still setup to build static libraries and not framework packages, so Xcode doesn't offer the same options as for Swift based native modules. Maybe we can use the |
@hansemannn It is failing because the architectures mentioned in manifest file is not same as in created XCFramework. Reason is, in _buildModule.js we are using hardcoded way to read architecture. Jan Vennemann is working on parsing of Info.plist available inside .xcframework as part of PR #12092 . After that we can update it to use architectures from there. It reminds me, should we fail the module build if manifest architectures do not match the architectures available in xcframework? Any how arm64 is in device and simulator both and x86_64 is in mac and simulator both. We can not verify exact architectures with current state of manifest. |
@vijaysingh-axway Thanks for the insight! So there is no workaround to compile the module? It's blocking our next update right now. Amy advice to work around it would help already! You can comment this line in your sdk (generated with this PR) and it should be good. |
@vijaysingh-axway With the latest change, the module compiles successfully already! The app build then fails with the following error:
I suppose that will be fixed by the changes from Jan then. EDIT: Workaround: Add the following to the two arch-checks inside _build.js: if (!fs.existsSync(path.join(module.libFile, archDir))) {
archDir = 'ios-arm64_x86_64-simulator';
}
if (!fs.existsSync(path.join(module.libFile, archDir))) {
this.logger.error(__('Cannot find matching architecture!!'));
process.exit(1);
} EDIT 2: But on device builds, it logs the following warning:
|
@hansemannn It should work now. |
@vijaysingh-axway The module build works, but the containing app cannot use the module in Simulator:
And same for device:
|
@@ -894,8 +917,6 @@ iOSModuleBuilder.prototype.runModule = function runModule(next) { | |||
|
|||
// 5. unzip module to the tmp dir. Use native binary on macOS, as AdmZip doesn't support symlinks used in mac catalyst frameworks | |||
const proc = spawn('unzip', [ '-o', this.moduleZipPath, '-d', tmpProjectDir ]); | |||
proc.stdout.on('data', data => this.logger.info(data.toString().trimEnd())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without these lines, the unzip never finished for me. We have to "consume" the stdout/stderr for it to finish.
iphone/cli/commands/_buildModule.js
Outdated
if (this.isMacOSEnabled) { | ||
lib = findLib('macosx'); | ||
if (lib instanceof Error) { | ||
this.logger.warn(__('The module is missing 64-bit support of macos. Ignoring mac target for this module...')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning is misleading. It's missing macOS support entirely, not 64-bit support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, they've "turned on" Mac support, so shouldn't this be an Error, not a warning log and move on?
// 3. Create a build for the maccatalyst | ||
xcodebuildHook(xcBuild, xcodeBuildArgumentsForTarget('macosx'), opts, 'xcode-macos', next); | ||
// 3. Create a build for the mac-catalyst if enabled | ||
if (this.isMacOSEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a dumb edge-case, but if they have no indication of Mac support in either a positive or negative value, what should we do? I think this will assume no macOS support, so will not try to build for it.
But if they haven't set SUPPORTS_MACCATALYST
in Xcode and they have no mac
key/value pair in the manifest
, then technically they haven't indicated one way or the other. Would we try to build for Mac and just be ok with it failing in that case?
@vijaysingh-axway I'm testing locally with WidgetKit and Facebook and cleaning up the commits. I'll force push and merge (if build is successful) afterwards. |
- based on if all libraries support arm64 sim. If not, exclude arm64 at build time - decide mac on basis of manifest (if available) or xcode target's SUPPORTS_MACCATALYST value - read info.plist to decide the xcframework archs
6fd53da
to
d862d43
Compare
OK, I've force-pushed a rebased set of commits that worked for me locally for both @hansemannn WidgetKit module and our Facebook Mac support PR. Note that on Hans' module I had to edit the manifest to remove For Facebook, I basically just had to point to the locally built SDK and set the manifest's |
@@ -107,7 +138,9 @@ iOSModuleBuilder.prototype.run = function run(logger, config, cli, finished) { | |||
'compileJS', | |||
'buildModule', | |||
'createUniversalBinary', | |||
'verifyBuildArch', | |||
function (next) { | |||
this.verifyBuildArch().then(next, next); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚠️ iphone/cli/commands/_buildModule.js line 142 – Avoid calling back inside of a promise. (promise/no-callback-in-promise)⚠️ iphone/cli/commands/_buildModule.js line 142 – Expected catch() or return (promise/catch-or-return)
@sgtcoolguy I wonder what's wrong with my config. I pulled the latest 9.2.0 build, updated the architectures and
It should not even attempt to pick up macOS because it's deactivated on both manifest and Xcode. This was my last commit to align with the latest changes. EDIT: 9.2.0.v20200922084018 may be too old already, because it does not contain your changes I think. Waiting for the new build then. |
Update: It seems like the latest 9.2.0 build is still not available, but building from source finally fixes the issue. Thanks everyone! |
Are there plans to finally fix all iOS 14 module issues and therefore make Titanium compatible with iOS 14+ modules? I filed this ticket to track it, but it may have been overseen so far :) |
https://jira.appcelerator.org/browse/TIMOB-28138