Skip to content

Commit ea7d5c0

Browse files
committed
fixups
1 parent b07472d commit ea7d5c0

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

packages/platform-apple-helpers/src/lib/commands/run/createRun.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export const createRun = async (
107107
);
108108

109109
if (platformName === 'macos') {
110-
if (!args.binaryPath) {
110+
let appPath = args.binaryPath;
111+
if (!appPath) {
111112
await buildProject({
112113
xcodeProject,
113114
sourceDir,
@@ -117,20 +118,21 @@ export const createRun = async (
117118
configuration,
118119
args,
119120
});
121+
const buildSettings = await getBuildSettings(
122+
xcodeProject,
123+
sourceDir,
124+
configuration,
125+
getSimulatorPlatformSDK(platformName),
126+
scheme
127+
);
128+
appPath = buildSettings.appPath;
120129
}
121-
const buildSettings = await getBuildSettings(
122-
xcodeProject,
123-
sourceDir,
124-
configuration,
125-
getSimulatorPlatformSDK(platformName),
126-
scheme
127-
);
128-
const appPath = args.binaryPath ?? buildSettings.appPath;
129130
await runOnMac(appPath);
130131
outro('Success 🎉.');
131132
return;
132133
} else if (args.catalyst) {
133-
if (!args.binaryPath) {
134+
let appPath = args.binaryPath;
135+
if (!appPath) {
134136
await buildProject({
135137
xcodeProject,
136138
sourceDir,
@@ -140,15 +142,15 @@ export const createRun = async (
140142
configuration,
141143
args,
142144
});
145+
const buildSettings = await getBuildSettings(
146+
xcodeProject,
147+
sourceDir,
148+
configuration,
149+
getSimulatorPlatformSDK(platformName),
150+
scheme
151+
);
152+
appPath = buildSettings.appPath;
143153
}
144-
const buildSettings = await getBuildSettings(
145-
xcodeProject,
146-
sourceDir,
147-
configuration,
148-
getSimulatorPlatformSDK(platformName),
149-
scheme
150-
);
151-
const appPath = args.binaryPath ?? buildSettings.appPath;
152154
await runOnMacCatalyst(appPath, scheme);
153155
outro('Success 🎉.');
154156
return;
@@ -191,7 +193,8 @@ export const createRun = async (
191193
const infoPlistPath = buildSettings.infoPlistPath;
192194
await runOnSimulator(device, appPath, infoPlistPath);
193195
} else if (device.type === 'device') {
194-
if (!args.binaryPath) {
196+
let appPath = args.binaryPath;
197+
if (!appPath) {
195198
await buildProject({
196199
xcodeProject,
197200
sourceDir,
@@ -201,15 +204,15 @@ export const createRun = async (
201204
configuration,
202205
args,
203206
});
207+
const buildSettings = await getBuildSettings(
208+
xcodeProject,
209+
sourceDir,
210+
configuration,
211+
getDevicePlatformSDK(platformName),
212+
scheme
213+
);
214+
appPath = buildSettings.appPath;
204215
}
205-
const buildSettings = await getBuildSettings(
206-
xcodeProject,
207-
sourceDir,
208-
configuration,
209-
getDevicePlatformSDK(platformName),
210-
scheme
211-
);
212-
const appPath = args.binaryPath ?? buildSettings.appPath;
213216
await runOnDevice(device, appPath, sourceDir);
214217
}
215218
outro('Success 🎉.');

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function runOnSimulator(
4141
loader.stop(`Installed the app on "${device.name}".`);
4242

4343
loader.start(`Launching the app on "${device.name}"`);
44-
await launchAppOnSimulator(device.udid, infoPlistPath);
44+
await launchAppOnSimulator(device.udid, binaryPath, infoPlistPath);
4545
loader.stop(`Launched the app on "${device.name}".`);
4646
}
4747

@@ -65,9 +65,14 @@ export default async function installAppOnSimulator(
6565

6666
export async function launchAppOnSimulator(
6767
udid: string,
68+
binaryPath: string,
6869
infoPlistPath: string
6970
) {
70-
const bundleID = await readKeyFromPlist(infoPlistPath, 'CFBundleIdentifier');
71+
const infoPlist = binaryPath
72+
? // @todo Info.plist is hardcoded when reading from binaryPath
73+
path.join(binaryPath, 'Info.plist')
74+
: infoPlistPath;
75+
const bundleID = await readKeyFromPlist(infoPlist, 'CFBundleIdentifier');
7176
logger.debug(`Launching "${bundleID}"`);
7277
try {
7378
await spawn('xcrun', ['simctl', 'launch', udid, bundleID]);

0 commit comments

Comments
 (0)