Skip to content

Commit 933f6cf

Browse files
feat: fallback to OOT scheme (#2233)
* feat: fallback to OOT scheme * Update packages/cli-platform-apple/src/commands/buildCommand/getConfiguration.ts Co-authored-by: Oskar Kwaśniewski <[email protected]> * fix: linter --------- Co-authored-by: Oskar Kwaśniewski <[email protected]>
1 parent c0c0cfa commit 933f6cf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/cli-platform-apple/src/commands/buildCommand/createBuild.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const createBuild =
4646
xcodeProject,
4747
sourceDir,
4848
args,
49+
platformName,
4950
);
5051

5152
return buildProject(

packages/cli-platform-apple/src/commands/buildCommand/getConfiguration.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {checkIfConfigurationExists} from '../../tools/checkIfConfigurationExists
77
import type {BuildFlags} from './buildOptions';
88
import {getBuildConfigurationFromXcScheme} from '../../tools/getBuildConfigurationFromXcScheme';
99
import path from 'path';
10+
import {getPlatformInfo} from '../runCommand/getPlatformInfo';
11+
import {ApplePlatform} from '../../types';
1012

1113
export async function getConfiguration(
1214
xcodeProject: IOSProjectInfo,
1315
sourceDir: string,
1416
args: BuildFlags,
17+
platformName: ApplePlatform,
1518
) {
1619
const info = getInfo();
1720

@@ -22,6 +25,24 @@ export async function getConfiguration(
2225
let scheme =
2326
args.scheme ||
2427
path.basename(xcodeProject.name, path.extname(xcodeProject.name));
28+
29+
if (!info?.schemes?.includes(scheme)) {
30+
const {readableName} = getPlatformInfo(platformName);
31+
const fallbackScheme = `${scheme}-${readableName}`;
32+
33+
if (info?.schemes?.includes(fallbackScheme)) {
34+
logger.warn(
35+
`Scheme "${chalk.bold(
36+
scheme,
37+
)}" doesn't exist. Using fallback scheme "${chalk.bold(
38+
fallbackScheme,
39+
)}"`,
40+
);
41+
42+
scheme = fallbackScheme;
43+
}
44+
}
45+
2546
let mode =
2647
args.mode ||
2748
getBuildConfigurationFromXcScheme(scheme, 'Debug', sourceDir, info);

packages/cli-platform-apple/src/commands/runCommand/createRun.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const createRun =
124124
xcodeProject,
125125
sourceDir,
126126
args,
127+
platformName,
127128
);
128129

129130
if (platformName === 'macos') {

0 commit comments

Comments
 (0)