88 "github.com/bitrise-io/go-xcode/certificateutil"
99 "github.com/bitrise-io/go-xcode/exportoptions"
1010 "github.com/bitrise-io/go-xcode/profileutil"
11+ "github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/mocks"
12+ "github.com/bitrise-io/go-xcode/v2/xcodeversion"
1113 "github.com/bitrise-io/go-xcode/xcodeproject/serialized"
1214 "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj"
1315 "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme"
@@ -129,6 +131,18 @@ const (
129131 <key>method</key>
130132 <string>development</string>
131133 </dict>
134+ </plist>`
135+ expectedNoProfilesDevelopmentXcode16ExportOptions = `<?xml version="1.0" encoding="UTF-8"?>
136+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
137+ <plist version="1.0">
138+ <dict>
139+ <key>distributionBundleIdentifier</key>
140+ <string>io.bundle.id</string>
141+ <key>iCloudContainerEnvironment</key>
142+ <string>Production</string>
143+ <key>method</key>
144+ <string>debugging</string>
145+ </dict>
132146</plist>`
133147 expectedNoProfilesXcode13AppStoreExportOptions = `<?xml version="1.0" encoding="UTF-8"?>
134148<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -141,6 +155,18 @@ const (
141155 <key>method</key>
142156 <string>app-store</string>
143157 </dict>
158+ </plist>`
159+ expectedNoProfilesXcode16AppStoreExportOptions = `<?xml version="1.0" encoding="UTF-8"?>
160+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
161+ <plist version="1.0">
162+ <dict>
163+ <key>iCloudContainerEnvironment</key>
164+ <string>Production</string>
165+ <key>manageAppVersionAndBuildNumber</key>
166+ <false/>
167+ <key>method</key>
168+ <string>app-store-connect</string>
169+ </dict>
144170</plist>`
145171 expectedNoProfilesAdHocExportOptions = `<?xml version="1.0" encoding="UTF-8"?>
146172<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -156,6 +182,12 @@ const (
156182</plist>`
157183)
158184
185+ func newXcodeVersionReader (t * testing.T , major int64 ) xcodeversion.Reader {
186+ reader := mocks .NewXcodeVersionReader (t )
187+ reader .On ("GetVersion" ).Return (xcodeversion.Version {Major : major }, nil )
188+ return reader
189+ }
190+
159191func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSigningStyle (t * testing.T ) {
160192 // Arrange
161193 const (
@@ -179,13 +211,13 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSig
179211 {
180212 name : "Default development exportOptions" ,
181213 exportMethod : exportoptions .MethodDevelopment ,
182- xcodeVersion : 15 ,
183214 generatorFactory : func () ExportOptionsGenerator {
184215 applicationTarget := givenApplicationTarget (nil )
185216 xcodeProj := givenXcodeproj ([]xcodeproj.Target {applicationTarget })
186217 scheme := givenScheme (applicationTarget )
218+ xcodeVersionReader := newXcodeVersionReader (t , 15 )
187219
188- g := New (& xcodeProj , & scheme , "" , logger )
220+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
189221 g .targetInfoProvider = MockTargetInfoProvider {
190222 bundleID : map [string ]string {"Application" : bundleID },
191223 }
@@ -208,13 +240,13 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSig
208240 {
209241 name : "Default app store exportOptions" ,
210242 exportMethod : exportoptions .MethodAppStore ,
211- xcodeVersion : 15 ,
212243 generatorFactory : func () ExportOptionsGenerator {
213244 applicationTarget := givenApplicationTarget (nil )
214245 xcodeProj := givenXcodeproj ([]xcodeproj.Target {applicationTarget })
215246 scheme := givenScheme (applicationTarget )
247+ xcodeVersionReader := newXcodeVersionReader (t , 15 )
216248
217- g := New (& xcodeProj , & scheme , "" , logger )
249+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
218250 g .targetInfoProvider = MockTargetInfoProvider {
219251 bundleID : map [string ]string {"Application" : bundleID },
220252 }
@@ -238,13 +270,13 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSig
238270 name : "When the app uses iCloud services" ,
239271 exportMethod : exportoptions .MethodDevelopment ,
240272 containerEnvironment : string (exportoptions .ICloudContainerEnvironmentProduction ),
241- xcodeVersion : 15 ,
242273 generatorFactory : func () ExportOptionsGenerator {
243274 applicationTarget := givenApplicationTarget (nil )
244275 xcodeProj := givenXcodeproj ([]xcodeproj.Target {applicationTarget })
245276 scheme := givenScheme (applicationTarget )
277+ xcodeVersionReader := newXcodeVersionReader (t , 15 )
246278
247- g := New (& xcodeProj , & scheme , "" , logger )
279+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
248280 g .targetInfoProvider = MockTargetInfoProvider {
249281 bundleID : map [string ]string {"Application" : bundleID },
250282 codesignEntitlements : map [string ]serialized.Object {"Application" : map [string ]interface {}{"com.apple.developer.icloud-services" : []string {"CloudKit" }}},
@@ -270,14 +302,14 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSig
270302 {
271303 name : "When exporting for TestFlight internal testing only" ,
272304 exportMethod : exportoptions .MethodAppStore ,
273- xcodeVersion : 15 ,
274305 testFlightInternalTestingOnly : true ,
275306 generatorFactory : func () ExportOptionsGenerator {
276307 applicationTarget := givenApplicationTarget (nil )
277308 xcodeProj := givenXcodeproj ([]xcodeproj.Target {applicationTarget })
278309 scheme := givenScheme (applicationTarget )
310+ xcodeVersionReader := newXcodeVersionReader (t , 15 )
279311
280- g := New (& xcodeProj , & scheme , "" , logger )
312+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
281313 g .targetInfoProvider = MockTargetInfoProvider {
282314 bundleID : map [string ]string {"Application" : bundleID },
283315 }
@@ -303,7 +335,7 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_ForAutomaticSig
303335 for _ , tt := range tests {
304336 t .Run (tt .name , func (t * testing.T ) {
305337 // Act
306- gotOpts , err := tt .generatorFactory ().GenerateApplicationExportOptions (tt .exportMethod , tt .containerEnvironment , teamID , true , true , false , exportoptions .SigningStyleAutomatic , tt .xcodeVersion , tt . testFlightInternalTestingOnly )
338+ gotOpts , err := tt .generatorFactory ().GenerateApplicationExportOptions (tt .exportMethod , tt .containerEnvironment , teamID , true , true , false , exportoptions .SigningStyleAutomatic , tt .testFlightInternalTestingOnly )
307339
308340 // Assert
309341 require .NoError (t , err )
@@ -372,7 +404,9 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions(t *testing.T) {
372404 scheme := givenScheme (applicationTarget )
373405 logger := log .NewLogger ()
374406 logger .EnableDebugLog (true )
375- g := New (& xcodeProj , & scheme , "" , logger )
407+ xcodeVersionReader := newXcodeVersionReader (t , tt .xcodeVersion )
408+
409+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
376410 g .certificateProvider = MockCodesignIdentityProvider {
377411 []certificateutil.CertificateInfoModel {certificate },
378412 }
@@ -405,7 +439,7 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions(t *testing.T) {
405439 }
406440
407441 // Act
408- gotOpts , err := g .GenerateApplicationExportOptions (tt .exportMethod , "Production" , teamID , true , true , false , exportoptions .SigningStyleManual , tt . xcodeVersion , true )
442+ gotOpts , err := g .GenerateApplicationExportOptions (tt .exportMethod , "Production" , teamID , true , true , false , exportoptions .SigningStyleManual , true )
409443
410444 // Assert
411445 require .NoError (t , err )
@@ -434,6 +468,12 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_WhenNoProfileFo
434468 want string
435469 wantErr bool
436470 }{
471+ {
472+ name : "When no profiles found, Xcode 16, using new export method name" ,
473+ exportMethod : exportoptions .MethodAppStore ,
474+ xcodeVersion : 16 ,
475+ want : expectedNoProfilesXcode16AppStoreExportOptions ,
476+ },
437477 {
438478 name : "When no profiles found, Xcode 13, then manageAppVersionAndBuildNumber is included" ,
439479 exportMethod : exportoptions .MethodAppStore ,
@@ -446,6 +486,12 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_WhenNoProfileFo
446486 xcodeVersion : 13 ,
447487 want : expectedNoProfilesAdHocExportOptions ,
448488 },
489+ {
490+ name : "When no profiles found, Xcode 16, usess new export method name" ,
491+ exportMethod : exportoptions .MethodDevelopment ,
492+ xcodeVersion : 16 ,
493+ want : expectedNoProfilesDevelopmentXcode16ExportOptions ,
494+ },
449495 {
450496 name : "When no profiles found, Xcode 11" ,
451497 exportMethod : exportoptions .MethodDevelopment ,
@@ -462,7 +508,9 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_WhenNoProfileFo
462508 scheme := givenScheme (applicationTarget )
463509 logger := log .NewLogger ()
464510 logger .EnableDebugLog (true )
465- g := New (& xcodeProj , & scheme , "" , logger )
511+ xcodeVersionReader := newXcodeVersionReader (t , tt .xcodeVersion )
512+
513+ g := New (& xcodeProj , & scheme , "" , xcodeVersionReader , logger )
466514 g .certificateProvider = MockCodesignIdentityProvider {
467515 []certificateutil.CertificateInfoModel {certificate },
468516 }
@@ -475,7 +523,7 @@ func TestExportOptionsGenerator_GenerateApplicationExportOptions_WhenNoProfileFo
475523 }
476524
477525 // Act
478- gotOpts , err := g .GenerateApplicationExportOptions (tt .exportMethod , "Production" , teamID , true , true , false , exportoptions .SigningStyleManual , tt . xcodeVersion , true )
526+ gotOpts , err := g .GenerateApplicationExportOptions (tt .exportMethod , "Production" , teamID , true , true , false , exportoptions .SigningStyleManual , true )
479527
480528 // Assert
481529 require .NoError (t , err )
0 commit comments