@@ -77,7 +77,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
7777 await checkSimulatorsAvailable ( platform ) ;
7878 }
7979
80- const destination = core . getInput ( 'destination' ) ;
80+ const destinationInput = core . getInput ( 'destination' ) ;
81+ let destination : string ;
82+
83+ if ( destinationInput ) {
84+ destination = destinationInput ;
85+ } else {
86+ destination = `generic/platform=${ platform } ` ;
87+ }
88+
8189 core . debug ( `Using destination: ${ destination } ` ) ;
8290 const bundleId = await getBuildSettings ( projectPath , scheme , platform , destination ) ;
8391 core . info ( `Bundle ID: ${ bundleId } ` ) ;
@@ -161,6 +169,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
161169 if ( projectRef . autoIncrementBuildNumber ) {
162170 let projectBundleVersionPrefix = '' ;
163171 let projectBundleVersionNumber : number ;
172+
164173 if ( ! cFBundleVersion || cFBundleVersion . length === 0 ) {
165174 projectBundleVersionNumber = 0 ;
166175 } else if ( cFBundleVersion . includes ( '.' ) ) {
@@ -170,26 +179,29 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
170179 } else {
171180 projectBundleVersionNumber = parseInt ( cFBundleVersion ) ;
172181 }
182+
173183 let lastVersionNumber : number ;
174184 let versionPrefix = '' ;
175185 let lastBundleVersion : string = null ;
186+
176187 try {
177188 lastBundleVersion = await GetLatestBundleVersion ( projectRef ) ;
178189 } catch ( error ) {
179190 if ( error instanceof UnauthorizedError ) {
180191 throw error ;
181192 }
182193 }
194+
183195 if ( ! lastBundleVersion || lastBundleVersion . length === 0 ) {
184196 lastVersionNumber = - 1 ;
185- }
186- else if ( lastBundleVersion . includes ( '.' ) ) {
197+ } else if ( lastBundleVersion . includes ( '.' ) ) {
187198 const versionParts = lastBundleVersion . split ( '.' ) ;
188199 lastVersionNumber = parseInt ( versionParts [ versionParts . length - 1 ] ) ;
189200 versionPrefix = versionParts . slice ( 0 , - 1 ) . join ( '.' ) + '.' ;
190201 } else {
191202 lastVersionNumber = parseInt ( lastBundleVersion ) ;
192203 }
204+
193205 if ( projectBundleVersionPrefix . length > 0 && projectBundleVersionPrefix !== versionPrefix ) {
194206 core . debug ( `Project version prefix: ${ projectBundleVersionPrefix } ` ) ;
195207 core . debug ( `Last bundle version prefix: ${ versionPrefix } ` ) ;
@@ -198,12 +210,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
198210 core . info ( `Updated project version prefix to: ${ projectBundleVersionPrefix } ` ) ;
199211 }
200212 }
213+
201214 if ( projectBundleVersionNumber <= lastVersionNumber ) {
202215 projectBundleVersionNumber = lastVersionNumber + 1 ;
203216 core . info ( `Auto Incremented bundle version ==> ${ versionPrefix } ${ projectBundleVersionNumber } ` ) ;
204217 }
218+
205219 infoPlist [ 'CFBundleVersion' ] = projectBundleVersionPrefix + projectBundleVersionNumber . toString ( ) ;
206220 projectRef . bundleVersion = projectBundleVersionPrefix + projectBundleVersionNumber . toString ( ) ;
221+
207222 try {
208223 await fs . promises . writeFile ( infoPlistPath , plist . build ( infoPlist ) ) ;
209224 } catch ( error ) {
@@ -213,13 +228,15 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
213228 } else {
214229 if ( projectRef . platform === 'macOS' ) {
215230 const notarizeInput = core . getInput ( 'notarize' ) || 'true' ;
231+
216232 core . debug ( `Notarize input: ${ notarizeInput } ` ) ;
217233 projectRef . notarize =
218234 notarizeInput === 'true' ||
219235 projectRef . isSteamBuild ||
220236 projectRef . archiveType === 'pkg' ||
221237 projectRef . archiveType === 'dmg' ;
222238 let output = '' ;
239+
223240 await exec ( 'security' , [
224241 'find-identity' ,
225242 '-v' , projectRef . credential . keychainPath
@@ -231,22 +248,27 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
231248 } ,
232249 silent : true
233250 } ) ;
251+
234252 if ( ! output . includes ( 'Developer ID Application' ) ) {
235253 throw new Error ( 'Developer ID Application not found! developer-id-application-certificate input is required for notarization.' ) ;
236254 }
255+
237256 if ( projectRef . archiveType === 'pkg' || projectRef . archiveType === 'dmg' ) {
238257 if ( ! output . includes ( 'Developer ID Installer' ) ) {
239258 throw new Error ( 'Developer ID Installer not found! developer-id-installer-certificate input is required for notarization.' ) ;
240259 }
241260 }
242261 }
243262 }
263+
244264 const plistHandle = await fs . promises . open ( infoPlistPath , fs . constants . O_RDONLY ) ;
265+
245266 try {
246267 infoPlistContent = await fs . promises . readFile ( plistHandle , 'utf8' ) ;
247268 } finally {
248269 await plistHandle . close ( ) ;
249270 }
271+
250272 core . info ( `------- Info.plist content: -------\n${ infoPlistContent } \n-----------------------------------` ) ;
251273 return projectRef ;
252274}
@@ -303,19 +325,44 @@ async function getSupportedPlatform(projectPath: string): Promise<string> {
303325 return platformMap [ platformName ] ;
304326}
305327
328+ async function getDestination ( projectPath : string , scheme : string , platform : string ) : Promise < string > {
329+ let destinationOutput = '' ;
330+
331+ const destinationArgs = [
332+ '-project' , projectPath ,
333+ '-scheme' , scheme ,
334+ '-showdestinations' ,
335+ '-json'
336+ ] ;
337+
338+ if ( ! core . isDebug ( ) ) {
339+ core . info ( `[command]${ xcodebuild } ${ destinationArgs . join ( ' ' ) } ` ) ;
340+ }
341+
342+ await exec ( xcodebuild , destinationArgs , {
343+ listeners : {
344+ stdout : ( data : Buffer ) => {
345+ destinationOutput += data . toString ( ) ;
346+ }
347+ } ,
348+ } ) ;
349+ core . info ( destinationOutput ) ;
350+ // example output:
351+ // TODO: parse the output to get the destination
352+ return `generic/platform=${ platform } ` ;
353+ }
354+
306355async function getBuildSettings ( projectPath : string , scheme : string , platform : string , destination : string | undefined ) : Promise < string > {
307356 let buildSettingsOutput = '' ;
308357
309358 const projectSettingsArgs = [
310359 'build' ,
311360 '-project' , projectPath ,
312- '-scheme' , scheme
361+ '-scheme' , scheme ,
362+ '-destination' , destination ,
363+ '-showBuildSettings'
313364 ] ;
314365
315- if ( destination ) {
316- projectSettingsArgs . push ( '-destination' , destination ) ;
317- }
318-
319366 projectSettingsArgs . push ( '-showBuildSettings' ) ;
320367
321368 if ( ! core . isDebug ( ) ) {
0 commit comments