2025-06-18 18:50:46 +02:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
exports . runIOS = void 0 ;
const tslib _1 = require ( "tslib" ) ;
const debug _1 = tslib _1 . _ _importDefault ( require ( "debug" ) ) ;
const path _1 = require ( "path" ) ;
const colors _1 = tslib _1 . _ _importDefault ( require ( "../colors" ) ) ;
const common _1 = require ( "../common" ) ;
const native _run _1 = require ( "../util/native-run" ) ;
const spm _1 = require ( "../util/spm" ) ;
const subprocess _1 = require ( "../util/subprocess" ) ;
const debug = ( 0 , debug _1 . default ) ( 'capacitor:ios:run' ) ;
2025-07-06 20:20:48 +02:00
async function runIOS ( config , { target : selectedTarget , scheme : selectedScheme , configuration : selectedConfiguration } ) {
2025-06-18 18:50:46 +02:00
const target = await ( 0 , common _1 . promptForPlatformTarget ) ( await ( 0 , native _run _1 . getPlatformTargets ) ( 'ios' ) , selectedTarget ) ;
const runScheme = selectedScheme || config . ios . scheme ;
const configuration = selectedConfiguration || 'Debug' ;
const derivedDataPath = ( 0 , path _1 . resolve ) ( config . ios . platformDirAbs , 'DerivedData' , target . id ) ;
const packageManager = await ( 0 , spm _1 . checkPackageManager ) ( config ) ;
let typeOfBuild ;
let projectName ;
if ( packageManager == 'Cocoapods' ) {
typeOfBuild = '-workspace' ;
projectName = ( 0 , path _1 . basename ) ( await config . ios . nativeXcodeWorkspaceDirAbs ) ;
}
else {
typeOfBuild = '-project' ;
projectName = ( 0 , path _1 . basename ) ( await config . ios . nativeXcodeProjDirAbs ) ;
}
const xcodebuildArgs = [
typeOfBuild ,
projectName ,
'-scheme' ,
runScheme ,
'-configuration' ,
configuration ,
'-destination' ,
` id= ${ target . id } ` ,
'-derivedDataPath' ,
derivedDataPath ,
] ;
debug ( 'Invoking xcodebuild with args: %O' , xcodebuildArgs ) ;
await ( 0 , common _1 . runTask ) ( 'Running xcodebuild' , async ( ) => ( 0 , subprocess _1 . runCommand ) ( 'xcrun' , [ 'xcodebuild' , ... xcodebuildArgs ] , {
cwd : config . ios . nativeProjectDirAbs ,
} ) ) ;
const appName = ` ${ runScheme } .app ` ;
2025-07-06 20:20:48 +02:00
const appPath = ( 0 , path _1 . resolve ) ( derivedDataPath , 'Build/Products' , target . virtual ? ` ${ configuration } -iphonesimulator ` : ` ${ configuration } -iphoneos ` , appName ) ;
2025-06-18 18:50:46 +02:00
const nativeRunArgs = [ 'ios' , '--app' , appPath , '--target' , target . id ] ;
debug ( 'Invoking native-run with args: %O' , nativeRunArgs ) ;
await ( 0 , common _1 . runTask ) ( ` Deploying ${ colors _1 . default . strong ( appName ) } to ${ colors _1 . default . input ( target . id ) } ` , async ( ) => ( 0 , native _run _1 . runNativeRun ) ( nativeRunArgs ) ) ;
}
exports . runIOS = runIOS ;