@@ -97,31 +97,37 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
9797 } ,
9898 silent : ! core . isDebug ( )
9999 } ) ;
100- // strip any previous string before json, bc xcodebuild outputs some text before the json :
100+ // Example output :
101101 // Available destinations for the "Unity-VisionOS" scheme:
102102 // { platform:visionOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-xrsimulator:placeholder, name:Any visionOS Simulator Device }
103103 // { platform:visionOS Simulator, arch:arm64, id:F1C1B167-8C5B-4737-B6A7-CF51DB6D5B70, OS:2.4, name:Apple Vision Pro }
104104 destinationOutput = destinationOutput . replace ( / A v a i l a b l e d e s t i n a t i o n s f o r t h e " .* " s c h e m e : \n / , '' ) ;
105- const destinations = JSON . parse ( destinationOutput ) ;
106- core . info ( `Available destinations: ${ JSON . stringify ( destinations , null , 2 ) } ` ) ;
105+ let lines = destinationOutput . split ( '\n' ) . filter ( line => line . trim ( ) !== '' ) ;
107106
108- if ( destinations . length === 0 ) {
109- throw new Error ( `No available destinations found for the project!\n ${ destinationOutput } ` ) ;
107+ if ( lines . length === 0 ) {
108+ throw new Error ( `No available destinations found for the project! Output: ${ destinationOutput } ` ) ;
110109 }
111110
112- const nameMatch = 'Any visionOS Simulator Device' ;
113- const matchedDestinations = destinations . filter ( ( d : any ) => d . name . includes ( nameMatch ) ) ;
111+ const destinations : any [ ] = [ ] ;
112+
113+ for ( const line of lines ) {
114+ try {
115+ const destination = JSON . parse ( line ) ;
116+ destinations . push ( destination ) ;
117+ } catch ( error ) {
118+ core . warning ( `Failed to parse destination line: ${ line } ` ) ;
119+ }
120+ }
114121
115- if ( matchedDestinations . length > 0 ) {
116- core . info ( `Using destination: ${ matchedDestinations [ 0 ] . name } ` ) ;
117- destination = `platform=${ matchedDestinations [ 0 ] . platform } ,id=${ matchedDestinations [ 0 ] . id } ,name=${ matchedDestinations [ 0 ] . name } ` ;
122+ if ( destinations . length === 0 ) {
123+ throw new Error ( `No available destinations found for the project!\n${ destinationOutput } ` ) ;
118124 }
119125
120126 if ( ! destination ) {
121127 core . info ( 'No specific destination set, using the first available destination.' ) ;
122128 for ( const dest of destinations ) {
123129 if ( dest . platform === platform ) {
124- destination = `platform= ${ dest . platform } ,id= ${ dest . id } ,name =${ dest . name } ` ;
130+ destination = Object . entries ( dest ) . map ( ( [ key , value ] ) => ` ${ key } =${ value } ` ) . join ( ',' ) ;
125131 break ;
126132 }
127133 }
@@ -131,30 +137,39 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
131137 core . debug ( `Using destination: ${ destination } ` ) ;
132138 const bundleId = await getBuildSettings ( projectPath , scheme , platform , destination ) ;
133139 core . info ( `Bundle ID: ${ bundleId } ` ) ;
140+
134141 if ( ! bundleId ) {
135142 throw new Error ( 'Unable to determine the bundle ID' ) ;
136143 }
144+
137145 let infoPlistPath = `${ projectDirectory } /${ projectName } /Info.plist` ;
146+
138147 if ( ! fs . existsSync ( infoPlistPath ) ) {
139148 infoPlistPath = `${ projectDirectory } /Info.plist` ;
140149 }
150+
141151 core . info ( `Info.plist path: ${ infoPlistPath } ` ) ;
142152 const infoPlistHandle = await fs . promises . open ( infoPlistPath , fs . constants . O_RDONLY ) ;
143153 let infoPlistContent : string ;
154+
144155 try {
145156 infoPlistContent = await fs . promises . readFile ( infoPlistHandle , 'utf8' ) ;
146157 } finally {
147158 await infoPlistHandle . close ( ) ;
148159 }
160+
149161 const infoPlist = plist . parse ( infoPlistContent ) as any ;
150162 let cFBundleShortVersionString : string = infoPlist [ 'CFBundleShortVersionString' ] ;
163+
151164 if ( cFBundleShortVersionString ) {
152165 const semverRegex = / ^ (?< major > \d + ) \. (?< minor > \d + ) \. (?< revision > \d + ) / ;
153166 const match = cFBundleShortVersionString . match ( semverRegex ) ;
167+
154168 if ( match ) {
155169 const { major, minor, revision } = match . groups as { [ key : string ] : string } ;
156170 cFBundleShortVersionString = `${ major } .${ minor } .${ revision } ` ;
157171 infoPlist [ 'CFBundleShortVersionString' ] = cFBundleShortVersionString . toString ( ) ;
172+
158173 try {
159174 core . info ( `Updating Info.plist with CFBundleShortVersionString: ${ cFBundleShortVersionString } ` ) ;
160175 await fs . promises . writeFile ( infoPlistPath , plist . build ( infoPlist ) ) ;
@@ -165,6 +180,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
165180 throw new Error ( `Invalid CFBundleShortVersionString format: ${ cFBundleShortVersionString } ` ) ;
166181 }
167182 }
183+
168184 core . info ( `CFBundleShortVersionString: ${ cFBundleShortVersionString } ` ) ;
169185 const cFBundleVersion = infoPlist [ 'CFBundleVersion' ] as string ;
170186 core . info ( `CFBundleVersion: ${ cFBundleVersion } ` ) ;
0 commit comments