Skip to content

Commit

Permalink
fix(ios/build): support passing target and device id to the module build
Browse files Browse the repository at this point in the history
The arguments are copied as is over to the app build process at the end of the module build,
there is also a change to return early in `initTiappSettings` in the app build. This is because
all build options are ran so `--device-id` to a module build triggers the app build checks, which
then subsequently fail. There is definitely a better fix for this, but this for now at least allows
it to work and unblocks the related VS Code feature
  • Loading branch information
ewanharris committed Apr 18, 2023
1 parent 4e6a526 commit 779b48a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 3 additions & 1 deletion iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,9 @@ iOSBuilder.prototype.configOptionWatchDeviceId = function configOptionWatchDevic
* error.
*/
iOSBuilder.prototype.initTiappSettings = function initTiappSettings() {
if (this._tiappSettingsInitialized) {
// This logic will also run on a module build when a --device-id argument is provided,
// so skip if we're not building an app.
if (this._tiappSettingsInitialized || this.cli.argv.type !== 'app') {
return;
}

Expand Down
33 changes: 22 additions & 11 deletions iphone/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ iOSModuleBuilder.prototype.validate = function validate(logger, config, cli) {

this.buildOnly = cli.argv['build-only'];
this.xcodeEnv = null;
this.target = cli.argv['target'];
this.deviceId = cli.argv['device-id'];

const sdkModuleAPIVersion = cli.sdk.manifest && cli.sdk.manifest.moduleAPIVersion && cli.sdk.manifest.moduleAPIVersion['iphone'];
if (this.manifest.apiversion && sdkModuleAPIVersion && this.manifest.apiversion !== sdkModuleAPIVersion) {
logger.error(__('The module manifest apiversion is currently set to %s', this.manifest.apiversion));
Expand Down Expand Up @@ -1078,17 +1081,25 @@ iOSModuleBuilder.prototype.runModule = function runModule(cli, next) {
function (cb) {
// 6. run the app
this.logger.debug(__('Running example project...', tmpDir.cyan));
runTiCommand(
[
'build',
'-p', 'ios',
'-d', tmpProjectDir,
'--no-prompt',
'--no-colors',
'--no-progress-bars'
],
cb
);
const buildArgs = [
'build',
'-p', 'ios',
'-d', tmpProjectDir,
'--no-prompt',
'--no-colors',
'--no-progress-bars'
];

if (this.target) {
buildArgs.push('-T');
buildArgs.push(this.target);
}
if (this.deviceId) {
buildArgs.push('-C');
buildArgs.push(this.deviceId);
}

runTiCommand(buildArgs, cb);
}
], next);
};
Expand Down

0 comments on commit 779b48a

Please sign in to comment.