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 4 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
63 changes: 44 additions & 19 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,25 +15,49 @@ export async function buildiOS(
): Promise<void> {
const theScheme = buildOptions.scheme ?? 'App';

await runTask('Building xArchive', async () =>
runCommand(
'xcodebuild',
[
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
'-scheme',
`${theScheme}`,
'-destination',
`generic/platform=iOS`,
'-archivePath',
`${theScheme}.xcarchive`,
'archive',
],
{
cwd: config.ios.nativeProjectDirAbs,
},
),
);
const packageManager = await checkPackageManager(config);

if (packageManager == 'Cocoapods') {
await runTask('Building xArchive', async () =>
runCommand(
'xcodebuild',
[
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
'-scheme',
`${theScheme}`,
'-destination',
`generic/platform=iOS`,
'-archivePath',
`${theScheme}.xcarchive`,
'archive',
],
{
cwd: config.ios.nativeProjectDirAbs,
},
),
);
} else {
await runTask('Building XCArchive - SPM', async () =>
runCommand(
'xcodebuild',
[
'-project',
basename(await config.ios.nativeXcodeProjDirAbs),
'-scheme',
`${theScheme}`,
'-destination',
`generic/platform=iOS`,
'-archivePath',
`${theScheme}.xcarchive`,
'archive',
],
{
cwd: config.ios.nativeProjectDirAbs,
},
),
);
}

const archivePlistContents = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down
43 changes: 31 additions & 12 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,18 +33,36 @@ export async function runIOS(
target.id,
);

const xcodebuildArgs = [
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
'-scheme',
runScheme,
'-configuration',
configuration,
'-destination',
`id=${target.id}`,
'-derivedDataPath',
derivedDataPath,
];
const packageManager = await checkPackageManager(config);
let xcodebuildArgs: string[];

if (packageManager == 'Cocoapods') {
xcodebuildArgs = [
'-workspace',
basename(await config.ios.nativeXcodeWorkspaceDirAbs),
'-scheme',
runScheme,
'-configuration',
configuration,
'-destination',
`id=${target.id}`,
'-derivedDataPath',
derivedDataPath,
];
} else {
xcodebuildArgs = [
'-project',
basename(await config.ios.nativeXcodeProjDirAbs),
'-scheme',
runScheme,
'-configuration',
configuration,
'-destination',
`id=${target.id}`,
'-derivedDataPath',
derivedDataPath,
];
}

debug('Invoking xcodebuild with args: %O', xcodebuildArgs);

Expand Down