Skip to content

Commit e4030ca

Browse files
authored
refactor: infer platform sdk from platform name for installApp (#69)
1 parent 8ddddb7 commit e4030ca

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/plugin-platform-apple/src/lib/commands/run/installApp.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ApplePlatform, XcodeProjectInfo } from '../../types/index.js';
66
import spawn, { SubprocessError } from 'nano-spawn';
77

88
type Options = {
9-
buildOutput: string;
109
xcodeProject: XcodeProjectInfo;
1110
sourceDir: string;
1211
mode: string;
@@ -18,7 +17,6 @@ type Options = {
1817
};
1918

2019
export default async function installApp({
21-
buildOutput,
2220
xcodeProject,
2321
sourceDir,
2422
mode,
@@ -34,7 +32,7 @@ export default async function installApp({
3432
xcodeProject,
3533
sourceDir,
3634
mode,
37-
buildOutput,
35+
`export PLATFORM_NAME=${getPlatformSDK(platform)}`, // simulate build output
3836
scheme,
3937
target
4038
);
@@ -86,3 +84,16 @@ export default async function installApp({
8684
throw error;
8785
}
8886
}
87+
88+
function getPlatformSDK(platform: ApplePlatform) {
89+
switch (platform) {
90+
case 'ios':
91+
return 'iphonesimulator';
92+
case 'macos':
93+
return 'macosx';
94+
case 'tvos':
95+
return 'appletvsimulator';
96+
case 'visionos':
97+
return 'xrsimulator';
98+
}
99+
}

packages/plugin-platform-apple/src/lib/commands/run/runOnSimulator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ export async function runOnSimulator(
4343
}
4444
loader.stop(`Launched Simulator "${simulator.name}".`);
4545

46-
let buildOutput;
4746
if (!binaryPath) {
48-
buildOutput = await buildProject(
47+
await buildProject(
4948
xcodeProject,
5049
sourceDir,
5150
platform,
@@ -58,7 +57,6 @@ export async function runOnSimulator(
5857

5958
loader.start(`Installing the app on "${simulator.name}"`);
6059
await installApp({
61-
buildOutput: buildOutput ?? '',
6260
xcodeProject,
6361
sourceDir,
6462
mode,

0 commit comments

Comments
 (0)