diff --git a/cli/src/android/run.ts b/cli/src/android/run.ts index e8910331f1..324c96ae41 100644 --- a/cli/src/android/run.ts +++ b/cli/src/android/run.ts @@ -12,14 +12,16 @@ const debug = Debug('capacitor:android:run'); export async function runAndroid( config: Config, - { target: selectedTarget }: RunCommandOptions, + { target: selectedTarget, flavor: selectedFlavor }: RunCommandOptions, ): Promise { const target = await promptForPlatformTarget( await getPlatformTargets('android'), selectedTarget, ); - const arg = `assemble${config.android?.flavor || ''}Debug`; + const runFlavor = selectedFlavor || config.android?.flavor || ''; + + const arg = `assemble${runFlavor}Debug`; const gradleArgs = [arg]; debug('Invoking ./gradlew with args: %O', gradleArgs); diff --git a/cli/src/index.ts b/cli/src/index.ts index f3c4eaf873..4d3c8c4853 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -137,6 +137,8 @@ export function runProgram(config: Config): void { .description( `runs ${c.input('sync')}, then builds and deploys the native app`, ) + .option('--scheme ', 'set the scheme of the iOS project') + .option('--flavor ', 'set the flavor of the Android project') .option('--list', 'list targets, then quit') // TODO: remove once --json is a hidden option (https://github.com/tj/commander.js/issues/1106) .allowUnknownOption(true) @@ -144,10 +146,19 @@ export function runProgram(config: Config): void { .option('--no-sync', `do not run ${c.input('sync')}`) .action( wrapAction( - telemetryAction(config, async (platform, { list, target, sync }) => { - const { runCommand } = await import('./tasks/run'); - await runCommand(config, platform, { list, target, sync }); - }), + telemetryAction( + config, + async (platform, { scheme, flavor, list, target, sync }) => { + const { runCommand } = await import('./tasks/run'); + await runCommand(config, platform, { + scheme, + flavor, + list, + target, + sync, + }); + }, + ), ), ); diff --git a/cli/src/ios/run.ts b/cli/src/ios/run.ts index 4347c562fa..4f3d8393ff 100644 --- a/cli/src/ios/run.ts +++ b/cli/src/ios/run.ts @@ -12,13 +12,15 @@ const debug = Debug('capacitor:ios:run'); export async function runIOS( config: Config, - { target: selectedTarget }: RunCommandOptions, + { target: selectedTarget, scheme: selectedScheme }: RunCommandOptions, ): Promise { const target = await promptForPlatformTarget( await getPlatformTargets('ios'), selectedTarget, ); + const runScheme = selectedScheme || config.ios.scheme; + const derivedDataPath = resolve( config.ios.platformDirAbs, 'DerivedData', @@ -29,7 +31,7 @@ export async function runIOS( '-workspace', basename(await config.ios.nativeXcodeWorkspaceDirAbs), '-scheme', - config.ios.scheme, + runScheme, '-configuration', 'Debug', '-destination', @@ -46,7 +48,7 @@ export async function runIOS( }), ); - const appName = `${config.ios.scheme}.app`; + const appName = `${runScheme}.app`; const appPath = resolve( derivedDataPath, 'Build/Products', diff --git a/cli/src/tasks/run.ts b/cli/src/tasks/run.ts index 17f2ae60ab..89ecc0e9ae 100644 --- a/cli/src/tasks/run.ts +++ b/cli/src/tasks/run.ts @@ -19,6 +19,8 @@ import { getPlatformTargets } from '../util/native-run'; import { sync } from './sync'; export interface RunCommandOptions { + scheme?: string; + flavor?: string; list?: boolean; target?: string; sync?: boolean;