Skip to content

Commit

Permalink
fix(cli): adjust SPM parameters for build and run commands (#7342)
Browse files Browse the repository at this point in the history
  • Loading branch information
markemer authored Mar 15, 2024
1 parent 7e68725 commit 02f8983
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions cli/src/ios/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { runTask } from '../common';
import type { Config } from '../definitions';
import { logSuccess } from '../log';
import type { BuildCommandOptions } from '../tasks/build';
import { checkPackageManager } from '../util/spm';
import { runCommand } from '../util/subprocess';

export async function buildiOS(
Expand All @@ -14,12 +15,25 @@ export async function buildiOS(
): Promise<void> {
const theScheme = buildOptions.scheme ?? 'App';

const packageManager = await checkPackageManager(config);

let typeOfBuild: string;
let projectName: string;

if (packageManager == 'Cocoapods') {
typeOfBuild = '-workspace';
projectName = basename(await config.ios.nativeXcodeWorkspaceDirAbs);
} else {
typeOfBuild = '-project';
projectName = basename(await config.ios.nativeXcodeProjDirAbs);
}

await runTask('Building xArchive', async () =>
runCommand(
'xcodebuild',
[
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
typeOfBuild,
projectName,
'-scheme',
`${theScheme}`,
'-destination',
Expand Down
18 changes: 16 additions & 2 deletions cli/src/ios/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { promptForPlatformTarget, runTask } from '../common';
import type { Config } from '../definitions';
import type { RunCommandOptions } from '../tasks/run';
import { runNativeRun, getPlatformTargets } from '../util/native-run';
import { checkPackageManager } from '../util/spm';
import { runCommand } from '../util/subprocess';

const debug = Debug('capacitor:ios:run');
Expand All @@ -32,9 +33,22 @@ export async function runIOS(
target.id,
);

const packageManager = await checkPackageManager(config);

let typeOfBuild: string;
let projectName: string;

if (packageManager == 'Cocoapods') {
typeOfBuild = '-workspace';
projectName = basename(await config.ios.nativeXcodeWorkspaceDirAbs);
} else {
typeOfBuild = '-project';
projectName = basename(await config.ios.nativeXcodeProjDirAbs);
}

const xcodebuildArgs = [
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
typeOfBuild,
projectName,
'-scheme',
runScheme,
'-configuration',
Expand Down

0 comments on commit 02f8983

Please sign in to comment.