Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): adjust SPM parameters for build and run commands #7342

Merged
merged 9 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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