Skip to content

Commit e17d9b0

Browse files
authored
feat(cli-platform-ios): Use run-ios to open Catalyst app after building (#1449)
`run-ios` was not opening the Catalyst app after building. This was due to two problems, which are addressed in this commit: * app target path was incorrect (needs to include -maccatalyst) * ios-deploy is the wrong tool to open a macos application
1 parent 66cdbde commit e17d9b0

File tree

1 file changed

+36
-18
lines changed
  • packages/platform-ios/src/commands/runIOS

1 file changed

+36
-18
lines changed

packages/platform-ios/src/commands/runIOS/index.ts

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,41 @@ async function runOnDevice(
265265
args,
266266
);
267267

268-
const iosDeployInstallArgs = [
269-
'--bundle',
270-
getBuildPath(xcodeProject, args.configuration, buildOutput, scheme),
271-
'--id',
272-
selectedDevice.udid,
273-
'--justlaunch',
274-
];
275-
276-
logger.info(`Installing and launching your app on ${selectedDevice.name}`);
268+
if (selectedDevice.type === 'catalyst') {
269+
const appPath = getBuildPath(
270+
xcodeProject,
271+
args.configuration,
272+
buildOutput,
273+
scheme,
274+
true,
275+
);
276+
const appProcess = child_process.spawn(`${appPath}/${scheme}`, [], {
277+
detached: true,
278+
stdio: 'ignore',
279+
});
280+
appProcess.unref();
281+
} else {
282+
const iosDeployInstallArgs = [
283+
'--bundle',
284+
getBuildPath(xcodeProject, args.configuration, buildOutput, scheme),
285+
'--id',
286+
selectedDevice.udid,
287+
'--justlaunch',
288+
];
277289

278-
const iosDeployOutput = child_process.spawnSync(
279-
'ios-deploy',
280-
iosDeployInstallArgs,
281-
{encoding: 'utf8'},
282-
);
290+
logger.info(`Installing and launching your app on ${selectedDevice.name}`);
283291

284-
if (iosDeployOutput.error) {
285-
throw new CLIError(
286-
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${iosDeployOutput.error.message}`,
292+
const iosDeployOutput = child_process.spawnSync(
293+
'ios-deploy',
294+
iosDeployInstallArgs,
295+
{encoding: 'utf8'},
287296
);
297+
298+
if (iosDeployOutput.error) {
299+
throw new CLIError(
300+
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${iosDeployOutput.error.message}`,
301+
);
302+
}
288303
}
289304

290305
return logger.success('Installed the app on the device.');
@@ -415,6 +430,7 @@ function getBuildPath(
415430
configuration: string,
416431
buildOutput: string,
417432
scheme: string,
433+
isCatalyst: boolean = false,
418434
) {
419435
const buildSettings = child_process.execFileSync(
420436
'xcodebuild',
@@ -442,7 +458,9 @@ function getBuildPath(
442458
throw new CLIError('Failed to get the app name.');
443459
}
444460

445-
return `${targetBuildDir}/${executableFolderPath}`;
461+
return `${targetBuildDir}${
462+
isCatalyst ? '-maccatalyst' : ''
463+
}/${executableFolderPath}`;
446464
}
447465

448466
function getPlatformName(buildOutput: string) {

0 commit comments

Comments
 (0)