From 78e990ca69f6c4386e2d3fffbaa17865f7aaa1ab Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:51:36 +0200 Subject: [PATCH 1/7] Add new export methods --- exportoptions/appstore_options.go | 7 +- exportoptions/exportoptions.go | 28 +++++++ exportoptions/exportoptions_test.go | 109 ++++++++++++++++++++++---- exportoptions/non_appstore_options.go | 7 +- exportoptions/properties.go | 21 +++++ 5 files changed, 154 insertions(+), 18 deletions(-) diff --git a/exportoptions/appstore_options.go b/exportoptions/appstore_options.go index 9eebcdd3..b6cf3c55 100644 --- a/exportoptions/appstore_options.go +++ b/exportoptions/appstore_options.go @@ -24,22 +24,25 @@ type AppStoreOptionsModel struct { ManageAppVersion bool TestFlightInternalTestingOnly bool + + useNewExportMethods bool } // NewAppStoreOptions ... -func NewAppStoreOptions() AppStoreOptionsModel { +func NewAppStoreOptions(useNewExportMethods bool) AppStoreOptionsModel { return AppStoreOptionsModel{ UploadBitcode: UploadBitcodeDefault, UploadSymbols: UploadSymbolsDefault, ManageAppVersion: manageAppVersionDefault, TestFlightInternalTestingOnly: TestFlightInternalTestingOnlyDefault, + useNewExportMethods: useNewExportMethods, } } // Hash ... func (options AppStoreOptionsModel) Hash() map[string]interface{} { hash := map[string]interface{}{} - hash[MethodKey] = MethodAppStore + hash[MethodKey] = mapMethodToExportOptionsMethod(MethodAppStore, options.useNewExportMethods) if options.TeamID != "" { hash[TeamIDKey] = options.TeamID } diff --git a/exportoptions/exportoptions.go b/exportoptions/exportoptions.go index 7e0cdf90..5ae5ab29 100644 --- a/exportoptions/exportoptions.go +++ b/exportoptions/exportoptions.go @@ -44,3 +44,31 @@ func WritePlistToTmpFile(options map[string]interface{}) (string, error) { return pth, nil } + +func mapMethodToExportOptionsMethod(method Method, useNewExportMethods bool) exportOptionsMethod { + switch method { + case MethodAppStore: + if useNewExportMethods { + return exportOptionsMethodAppStoreConnect + } + return exportOptionsMethodAppStore + case MethodAdHoc: + if useNewExportMethods { + return ExportOptionsMethodReleaseTesting + } + return exportOptionsMethodAdHoc + case MethodEnterprise: + return exportOptionsMethodEnterprise + case MethodDevelopment: + if useNewExportMethods { + return exportOptionsMethodDebugging + } + return exportOptionsMethodDevelopment + case MethodPackage: + return exportOptionsMethodPackage + case MethodDeveloperID: + return exportOptionsMethodDeveloperID + default: + panic(fmt.Sprintf("unkown method (%s)", method)) + } +} diff --git a/exportoptions/exportoptions_test.go b/exportoptions/exportoptions_test.go index 468e910e..c1e4567c 100644 --- a/exportoptions/exportoptions_test.go +++ b/exportoptions/exportoptions_test.go @@ -108,7 +108,7 @@ func TestManifestToHash(t *testing.T) { func TestNewAppStoreOptions(t *testing.T) { t.Log("create app-store type export options with default values") { - options := NewAppStoreOptions() + options := NewAppStoreOptions(true) require.Equal(t, UploadBitcodeDefault, options.UploadBitcode) require.Equal(t, UploadSymbolsDefault, options.UploadSymbols) require.Equal(t, TestFlightInternalTestingOnlyDefault, options.TestFlightInternalTestingOnly) @@ -116,9 +116,9 @@ func TestNewAppStoreOptions(t *testing.T) { } func TestAppStoreOptionsToHash(t *testing.T) { - t.Log("default app-store type options creates hash with method") + t.Log("default app-store type options creates hash with legacy method") { - options := NewAppStoreOptions() + options := NewAppStoreOptions(false) options.ManageAppVersion = true hash := options.Hash() require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash)) @@ -126,13 +126,27 @@ func TestAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.Equal(t, true, ok) - require.Equal(t, MethodAppStore, value) + require.Equal(t, exportOptionsMethodAppStore, value) + } + } + + t.Log("default app-store type options creates hash with new method") + { + options := NewAppStoreOptions(true) + options.ManageAppVersion = true + hash := options.Hash() + require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash)) + + { + value, ok := hash[MethodKey] + require.Equal(t, true, ok) + require.Equal(t, exportOptionsMethodAppStoreConnect, value) } } t.Log("custom app-store type option's generated hash contains all properties") { - options := NewAppStoreOptions() + options := NewAppStoreOptions(false) options.TeamID = "123" options.UploadBitcode = false options.UploadSymbols = false @@ -145,7 +159,7 @@ func TestAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.True(t, ok) - require.Equal(t, MethodAppStore, value) + require.Equal(t, exportOptionsMethodAppStore, value) } { value, ok := hash[TeamIDKey] @@ -182,7 +196,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewAppStoreOptions() + options := NewAppStoreOptions(false) options.ManageAppVersion = true require.NoError(t, options.WriteToFile(pth)) @@ -205,7 +219,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewAppStoreOptions() + options := NewAppStoreOptions(false) options.TeamID = "123" options.UploadBitcode = false options.UploadSymbols = false @@ -237,7 +251,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { func TestNonNewAppStoreOptions(t *testing.T) { t.Log("create NON app-store type export options with default values") { - options := NewNonAppStoreOptions(MethodDevelopment) + options := NewNonAppStoreOptions(MethodDevelopment, false) require.Equal(t, MethodDevelopment, options.Method) require.Equal(t, CompileBitcodeDefault, options.CompileBitcode) require.Equal(t, EmbedOnDemandResourcesAssetPacksInBundleDefault, options.EmbedOnDemandResourcesAssetPacksInBundle) @@ -249,20 +263,20 @@ func TestNonNewAppStoreOptions(t *testing.T) { func TestNonAppStoreOptionsToHash(t *testing.T) { t.Log("default NON app-store type options creates hash with method") { - options := NewNonAppStoreOptions(MethodDevelopment) + options := NewNonAppStoreOptions(MethodDevelopment, false) hash := options.Hash() require.Equal(t, 1, len(hash)) { value, ok := hash[MethodKey] require.Equal(t, true, ok) - require.Equal(t, MethodDevelopment, value) + require.Equal(t, exportOptionsMethodDevelopment, value) } } t.Log("custom NON app-store type option's generated hash contains all properties") { - options := NewNonAppStoreOptions(MethodEnterprise) + options := NewNonAppStoreOptions(MethodEnterprise, false) options.TeamID = "123" options.CompileBitcode = false options.EmbedOnDemandResourcesAssetPacksInBundle = false @@ -350,7 +364,7 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewNonAppStoreOptions(MethodEnterprise) + options := NewNonAppStoreOptions(MethodEnterprise, false) require.NoError(t, options.WriteToFile(pth)) content, err := fileutil.ReadStringFromFile(pth) @@ -372,7 +386,7 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewNonAppStoreOptions(MethodEnterprise) + options := NewNonAppStoreOptions(MethodEnterprise, false) options.TeamID = "123" options.CompileBitcode = false options.EmbedOnDemandResourcesAssetPacksInBundle = false @@ -424,3 +438,70 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.Equal(t, desired, content) } } + +func Test_mapMethodToExportOptionsMethod(t *testing.T) { + tests := []struct { + name string + method Method + useNewExportMethods bool + want exportOptionsMethod + }{ + { + method: "app-store", + useNewExportMethods: false, + want: "app-store", + }, + { + method: "app-store", + useNewExportMethods: true, + want: "app-store-connect", + }, + { + method: "ad-hoc", + useNewExportMethods: false, + want: "ad-hoc", + }, + { + method: "ad-hoc", + useNewExportMethods: true, + want: "release-testing", + }, + { + method: "enterprise", + useNewExportMethods: false, + want: "enterprise", + }, + { + method: "enterprise", + useNewExportMethods: true, + want: "enterprise", + }, + { + method: "development", + useNewExportMethods: false, + want: "development", + }, + { + method: "development", + useNewExportMethods: true, + want: "debugging", + }, + { + method: "package", + useNewExportMethods: true, + want: "package", + }, + { + method: "developer-id", + useNewExportMethods: true, + want: "developer-id", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := mapMethodToExportOptionsMethod(tt.method, tt.useNewExportMethods); got != tt.want { + t.Errorf("mapMethodToExportOptionsMethod() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/exportoptions/non_appstore_options.go b/exportoptions/non_appstore_options.go index 5a2a03e5..5a4063ee 100644 --- a/exportoptions/non_appstore_options.go +++ b/exportoptions/non_appstore_options.go @@ -23,15 +23,18 @@ type NonAppStoreOptionsModel struct { Manifest Manifest OnDemandResourcesAssetPacksBaseURL string Thinning string + + useNewExportMethods bool } // NewNonAppStoreOptions ... -func NewNonAppStoreOptions(method Method) NonAppStoreOptionsModel { +func NewNonAppStoreOptions(method Method, useNewExportMethods bool) NonAppStoreOptionsModel { return NonAppStoreOptionsModel{ Method: method, CompileBitcode: CompileBitcodeDefault, EmbedOnDemandResourcesAssetPacksInBundle: EmbedOnDemandResourcesAssetPacksInBundleDefault, Thinning: ThinningDefault, + useNewExportMethods: useNewExportMethods, } } @@ -39,7 +42,7 @@ func NewNonAppStoreOptions(method Method) NonAppStoreOptionsModel { func (options NonAppStoreOptionsModel) Hash() map[string]interface{} { hash := map[string]interface{}{} if options.Method != "" { - hash[MethodKey] = options.Method + hash[MethodKey] = mapMethodToExportOptionsMethod(options.Method, options.useNewExportMethods) } if options.TeamID != "" { hash[TeamIDKey] = options.TeamID diff --git a/exportoptions/properties.go b/exportoptions/properties.go index 84f8d194..5f858ec6 100644 --- a/exportoptions/properties.go +++ b/exportoptions/properties.go @@ -119,6 +119,27 @@ func ParseMethod(method string) (Method, error) { } } +type exportOptionsMethod string + +const ( + exportOptionsMethodAppStore exportOptionsMethod = "app-store" + // "app-store-connect" is the new name for "app-store" since Xcode 15.3 + exportOptionsMethodAppStoreConnect exportOptionsMethod = "app-store-connect" + + exportOptionsMethodAdHoc exportOptionsMethod = "ad-hoc" + // "release-testing" is the new name for "ad-hoc" since Xcode 15.3 + ExportOptionsMethodReleaseTesting exportOptionsMethod = "release-testing" + + exportOptionsMethodEnterprise exportOptionsMethod = "enterprise" + + exportOptionsMethodDevelopment exportOptionsMethod = "development" + // "debugging" is the new name for "development" since Xcode 15.3 + exportOptionsMethodDebugging exportOptionsMethod = "debugging" + + exportOptionsMethodPackage exportOptionsMethod = "package" + exportOptionsMethodDeveloperID exportOptionsMethod = "developer-id" +) + // OnDemandResourcesAssetPacksBaseURLKey .... const OnDemandResourcesAssetPacksBaseURLKey = "onDemandResourcesAssetPacksBaseURL" From d051723c2ba6e1d8cc299df03cc1cf784a82ce56 Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 11:48:54 +0200 Subject: [PATCH 2/7] Use single method type: --- exportoptions/appstore_options.go | 21 +++++-- exportoptions/exportoptions.go | 28 --------- exportoptions/exportoptions_test.go | 91 ++++----------------------- exportoptions/non_appstore_options.go | 2 +- exportoptions/properties.go | 61 +++++++++++------- exportoptions/properties_test.go | 37 +++++++++++ 6 files changed, 104 insertions(+), 136 deletions(-) create mode 100644 exportoptions/properties_test.go diff --git a/exportoptions/appstore_options.go b/exportoptions/appstore_options.go index b6cf3c55..cbd17908 100644 --- a/exportoptions/appstore_options.go +++ b/exportoptions/appstore_options.go @@ -8,6 +8,7 @@ import ( // AppStoreOptionsModel ... type AppStoreOptionsModel struct { + Method Method TeamID string BundleIDProvisioningProfileMapping map[string]string SigningCertificate string @@ -24,25 +25,35 @@ type AppStoreOptionsModel struct { ManageAppVersion bool TestFlightInternalTestingOnly bool +} - useNewExportMethods bool +// NewAppStoreOptions sets "app-store" as the export method +// use NewAppStoreConnectOptions instead (from Xcode 15.3) +func NewAppStoreOptions() AppStoreOptionsModel { + return AppStoreOptionsModel{ + Method: MethodAppStore, + UploadBitcode: UploadBitcodeDefault, + UploadSymbols: UploadSymbolsDefault, + ManageAppVersion: manageAppVersionDefault, + TestFlightInternalTestingOnly: TestFlightInternalTestingOnlyDefault, + } } -// NewAppStoreOptions ... -func NewAppStoreOptions(useNewExportMethods bool) AppStoreOptionsModel { +// NewAppStoreConnectOptions sets "app-store-connect" as the export method +func NewAppStoreConnectOptions() AppStoreOptionsModel { return AppStoreOptionsModel{ + Method: MethodAppStoreConnect, UploadBitcode: UploadBitcodeDefault, UploadSymbols: UploadSymbolsDefault, ManageAppVersion: manageAppVersionDefault, TestFlightInternalTestingOnly: TestFlightInternalTestingOnlyDefault, - useNewExportMethods: useNewExportMethods, } } // Hash ... func (options AppStoreOptionsModel) Hash() map[string]interface{} { hash := map[string]interface{}{} - hash[MethodKey] = mapMethodToExportOptionsMethod(MethodAppStore, options.useNewExportMethods) + hash[MethodKey] = options.Method if options.TeamID != "" { hash[TeamIDKey] = options.TeamID } diff --git a/exportoptions/exportoptions.go b/exportoptions/exportoptions.go index 5ae5ab29..7e0cdf90 100644 --- a/exportoptions/exportoptions.go +++ b/exportoptions/exportoptions.go @@ -44,31 +44,3 @@ func WritePlistToTmpFile(options map[string]interface{}) (string, error) { return pth, nil } - -func mapMethodToExportOptionsMethod(method Method, useNewExportMethods bool) exportOptionsMethod { - switch method { - case MethodAppStore: - if useNewExportMethods { - return exportOptionsMethodAppStoreConnect - } - return exportOptionsMethodAppStore - case MethodAdHoc: - if useNewExportMethods { - return ExportOptionsMethodReleaseTesting - } - return exportOptionsMethodAdHoc - case MethodEnterprise: - return exportOptionsMethodEnterprise - case MethodDevelopment: - if useNewExportMethods { - return exportOptionsMethodDebugging - } - return exportOptionsMethodDevelopment - case MethodPackage: - return exportOptionsMethodPackage - case MethodDeveloperID: - return exportOptionsMethodDeveloperID - default: - panic(fmt.Sprintf("unkown method (%s)", method)) - } -} diff --git a/exportoptions/exportoptions_test.go b/exportoptions/exportoptions_test.go index c1e4567c..cc096460 100644 --- a/exportoptions/exportoptions_test.go +++ b/exportoptions/exportoptions_test.go @@ -105,10 +105,10 @@ func TestManifestToHash(t *testing.T) { } } -func TestNewAppStoreOptions(t *testing.T) { +func TestNewAppStoreConnectOptions(t *testing.T) { t.Log("create app-store type export options with default values") { - options := NewAppStoreOptions(true) + options := NewAppStoreConnectOptions() require.Equal(t, UploadBitcodeDefault, options.UploadBitcode) require.Equal(t, UploadSymbolsDefault, options.UploadSymbols) require.Equal(t, TestFlightInternalTestingOnlyDefault, options.TestFlightInternalTestingOnly) @@ -118,7 +118,7 @@ func TestNewAppStoreOptions(t *testing.T) { func TestAppStoreOptionsToHash(t *testing.T) { t.Log("default app-store type options creates hash with legacy method") { - options := NewAppStoreOptions(false) + options := NewAppStoreOptions() options.ManageAppVersion = true hash := options.Hash() require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash)) @@ -126,13 +126,13 @@ func TestAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.Equal(t, true, ok) - require.Equal(t, exportOptionsMethodAppStore, value) + require.Equal(t, MethodAppStore, value) } } t.Log("default app-store type options creates hash with new method") { - options := NewAppStoreOptions(true) + options := NewAppStoreConnectOptions() options.ManageAppVersion = true hash := options.Hash() require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash)) @@ -140,13 +140,13 @@ func TestAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.Equal(t, true, ok) - require.Equal(t, exportOptionsMethodAppStoreConnect, value) + require.Equal(t, MethodAppStoreConnect, value) } } t.Log("custom app-store type option's generated hash contains all properties") { - options := NewAppStoreOptions(false) + options := NewAppStoreOptions() options.TeamID = "123" options.UploadBitcode = false options.UploadSymbols = false @@ -159,7 +159,7 @@ func TestAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.True(t, ok) - require.Equal(t, exportOptionsMethodAppStore, value) + require.Equal(t, MethodAppStore, value) } { value, ok := hash[TeamIDKey] @@ -196,7 +196,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewAppStoreOptions(false) + options := NewAppStoreConnectOptions() options.ManageAppVersion = true require.NoError(t, options.WriteToFile(pth)) @@ -207,7 +207,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { method - app-store + app-store-connect ` require.Equal(t, desired, content) @@ -219,7 +219,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewAppStoreOptions(false) + options := NewAppStoreOptions() options.TeamID = "123" options.UploadBitcode = false options.UploadSymbols = false @@ -270,7 +270,7 @@ func TestNonAppStoreOptionsToHash(t *testing.T) { { value, ok := hash[MethodKey] require.Equal(t, true, ok) - require.Equal(t, exportOptionsMethodDevelopment, value) + require.Equal(t, MethodDevelopment, value) } } @@ -438,70 +438,3 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.Equal(t, desired, content) } } - -func Test_mapMethodToExportOptionsMethod(t *testing.T) { - tests := []struct { - name string - method Method - useNewExportMethods bool - want exportOptionsMethod - }{ - { - method: "app-store", - useNewExportMethods: false, - want: "app-store", - }, - { - method: "app-store", - useNewExportMethods: true, - want: "app-store-connect", - }, - { - method: "ad-hoc", - useNewExportMethods: false, - want: "ad-hoc", - }, - { - method: "ad-hoc", - useNewExportMethods: true, - want: "release-testing", - }, - { - method: "enterprise", - useNewExportMethods: false, - want: "enterprise", - }, - { - method: "enterprise", - useNewExportMethods: true, - want: "enterprise", - }, - { - method: "development", - useNewExportMethods: false, - want: "development", - }, - { - method: "development", - useNewExportMethods: true, - want: "debugging", - }, - { - method: "package", - useNewExportMethods: true, - want: "package", - }, - { - method: "developer-id", - useNewExportMethods: true, - want: "developer-id", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := mapMethodToExportOptionsMethod(tt.method, tt.useNewExportMethods); got != tt.want { - t.Errorf("mapMethodToExportOptionsMethod() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/exportoptions/non_appstore_options.go b/exportoptions/non_appstore_options.go index 5a4063ee..75b4b528 100644 --- a/exportoptions/non_appstore_options.go +++ b/exportoptions/non_appstore_options.go @@ -42,7 +42,7 @@ func NewNonAppStoreOptions(method Method, useNewExportMethods bool) NonAppStoreO func (options NonAppStoreOptionsModel) Hash() map[string]interface{} { hash := map[string]interface{}{} if options.Method != "" { - hash[MethodKey] = mapMethodToExportOptionsMethod(options.Method, options.useNewExportMethods) + hash[MethodKey] = options.Method } if options.TeamID != "" { hash[TeamIDKey] = options.TeamID diff --git a/exportoptions/properties.go b/exportoptions/properties.go index 5f858ec6..b8cb9317 100644 --- a/exportoptions/properties.go +++ b/exportoptions/properties.go @@ -83,23 +83,45 @@ const MethodKey = "method" type Method string const ( - // MethodAppStore ... + // MethodAppStore is deprecated since Xcode 15.3, its new name is MethodAppStoreConnect MethodAppStore Method = "app-store" - // MethodAdHoc ... + // MethodAdHoc is deprecated since Xcode 15.3, its new name is MethodReleaseTesting MethodAdHoc Method = "ad-hoc" // MethodPackage ... MethodPackage Method = "package" // MethodEnterprise ... MethodEnterprise Method = "enterprise" - // MethodDevelopment ... + // MethodDevelopment is deprecated since Xcode 15.3, its new name is MethodDebugging MethodDevelopment Method = "development" // MethodDeveloperID ... MethodDeveloperID Method = "developer-id" + // MethodDebugging is the new name for MethodDevelopment since Xcode 15.3 + MethodDebugging Method = "debugging" + // MethodAppStoreConnect is the new name for MethodAppStore since Xcode 15.3 + MethodAppStoreConnect Method = "app-store-connect" + // MethodReleaseTesting is the new name for MethodAdHoc since Xcode 15.3 + MethodReleaseTesting Method = "release-testing" // MethodDefault ... MethodDefault Method = MethodDevelopment ) -// ParseMethod ... +func (m Method) IsAppStore() bool { + return m == MethodAppStore || m == MethodAppStoreConnect +} + +func (m Method) IsAdHoc() bool { + return m == MethodAdHoc || m == MethodReleaseTesting +} + +func (m Method) IsDevelopment() bool { + return m == MethodDevelopment || m == MethodDebugging +} + +func (m Method) IsEnterprise() bool { + return m == MethodEnterprise +} + +// ParseMethod parses Step input and returns the corresponding Method. func ParseMethod(method string) (Method, error) { switch method { case "app-store": @@ -119,26 +141,19 @@ func ParseMethod(method string) (Method, error) { } } -type exportOptionsMethod string - -const ( - exportOptionsMethodAppStore exportOptionsMethod = "app-store" - // "app-store-connect" is the new name for "app-store" since Xcode 15.3 - exportOptionsMethodAppStoreConnect exportOptionsMethod = "app-store-connect" - - exportOptionsMethodAdHoc exportOptionsMethod = "ad-hoc" - // "release-testing" is the new name for "ad-hoc" since Xcode 15.3 - ExportOptionsMethodReleaseTesting exportOptionsMethod = "release-testing" - - exportOptionsMethodEnterprise exportOptionsMethod = "enterprise" - - exportOptionsMethodDevelopment exportOptionsMethod = "development" - // "debugging" is the new name for "development" since Xcode 15.3 - exportOptionsMethodDebugging exportOptionsMethod = "debugging" +// UpgradeExportMethod replaces the legacy export method strings with the ones available in Xcode 15.3 and later. +func UpgradeExportMethod(method Method) Method { + switch method { + case MethodAppStore: + return MethodAppStoreConnect + case MethodAdHoc: + return MethodReleaseTesting + case MethodDevelopment: + return MethodDebugging + } - exportOptionsMethodPackage exportOptionsMethod = "package" - exportOptionsMethodDeveloperID exportOptionsMethod = "developer-id" -) + return method +} // OnDemandResourcesAssetPacksBaseURLKey .... const OnDemandResourcesAssetPacksBaseURLKey = "onDemandResourcesAssetPacksBaseURL" diff --git a/exportoptions/properties_test.go b/exportoptions/properties_test.go new file mode 100644 index 00000000..0e681dd6 --- /dev/null +++ b/exportoptions/properties_test.go @@ -0,0 +1,37 @@ +package exportoptions + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestUpgradeExportMethod(t *testing.T) { + tests := []struct { + name string + method Method + want Method + }{ + { + method: "app-store", + want: "app-store-connect", + }, + { + method: "ad-hoc", + want: "release-testing", + }, + { + method: "development", + want: "debugging", + }, + { + method: "developer-id", + want: "developer-id", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, UpgradeExportMethod(tt.method)) + }) + } +} From 8b18b3fc5b8dc9b306d232d61b0d6173540ce8e2 Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 12:03:37 +0200 Subject: [PATCH 3/7] minor improvements --- exportoptions/appstore_options.go | 11 +++++++---- exportoptions/non_appstore_options.go | 5 +---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/exportoptions/appstore_options.go b/exportoptions/appstore_options.go index cbd17908..99fc38b1 100644 --- a/exportoptions/appstore_options.go +++ b/exportoptions/appstore_options.go @@ -28,7 +28,7 @@ type AppStoreOptionsModel struct { } // NewAppStoreOptions sets "app-store" as the export method -// use NewAppStoreConnectOptions instead (from Xcode 15.3) +// deprecated: use NewAppStoreConnectOptions instead func NewAppStoreOptions() AppStoreOptionsModel { return AppStoreOptionsModel{ Method: MethodAppStore, @@ -39,10 +39,13 @@ func NewAppStoreOptions() AppStoreOptionsModel { } } -// NewAppStoreConnectOptions sets "app-store-connect" as the export method -func NewAppStoreConnectOptions() AppStoreOptionsModel { +// NewAppStoreConnectOptions sets either "app-store" or "app-store-connect" as the export method +func NewAppStoreConnectOptions(method Method) AppStoreOptionsModel { + if !method.IsAppStore() { + panic("non app-store method passed to NewAppStoreConnectOptions") + } return AppStoreOptionsModel{ - Method: MethodAppStoreConnect, + Method: method, UploadBitcode: UploadBitcodeDefault, UploadSymbols: UploadSymbolsDefault, ManageAppVersion: manageAppVersionDefault, diff --git a/exportoptions/non_appstore_options.go b/exportoptions/non_appstore_options.go index 75b4b528..5a2a03e5 100644 --- a/exportoptions/non_appstore_options.go +++ b/exportoptions/non_appstore_options.go @@ -23,18 +23,15 @@ type NonAppStoreOptionsModel struct { Manifest Manifest OnDemandResourcesAssetPacksBaseURL string Thinning string - - useNewExportMethods bool } // NewNonAppStoreOptions ... -func NewNonAppStoreOptions(method Method, useNewExportMethods bool) NonAppStoreOptionsModel { +func NewNonAppStoreOptions(method Method) NonAppStoreOptionsModel { return NonAppStoreOptionsModel{ Method: method, CompileBitcode: CompileBitcodeDefault, EmbedOnDemandResourcesAssetPacksInBundle: EmbedOnDemandResourcesAssetPacksInBundleDefault, Thinning: ThinningDefault, - useNewExportMethods: useNewExportMethods, } } From 8d73ab5ff81aca716d0bbdef061bd56f1c099924 Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 12:16:57 +0200 Subject: [PATCH 4/7] fix tests --- exportoptions/exportoptions_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exportoptions/exportoptions_test.go b/exportoptions/exportoptions_test.go index cc096460..51be8c89 100644 --- a/exportoptions/exportoptions_test.go +++ b/exportoptions/exportoptions_test.go @@ -108,7 +108,7 @@ func TestManifestToHash(t *testing.T) { func TestNewAppStoreConnectOptions(t *testing.T) { t.Log("create app-store type export options with default values") { - options := NewAppStoreConnectOptions() + options := NewAppStoreConnectOptions(MethodAppStoreConnect) require.Equal(t, UploadBitcodeDefault, options.UploadBitcode) require.Equal(t, UploadSymbolsDefault, options.UploadSymbols) require.Equal(t, TestFlightInternalTestingOnlyDefault, options.TestFlightInternalTestingOnly) @@ -132,7 +132,7 @@ func TestAppStoreOptionsToHash(t *testing.T) { t.Log("default app-store type options creates hash with new method") { - options := NewAppStoreConnectOptions() + options := NewAppStoreConnectOptions(MethodAppStoreConnect) options.ManageAppVersion = true hash := options.Hash() require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash)) @@ -196,7 +196,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewAppStoreConnectOptions() + options := NewAppStoreConnectOptions(MethodAppStoreConnect) options.ManageAppVersion = true require.NoError(t, options.WriteToFile(pth)) @@ -251,7 +251,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) { func TestNonNewAppStoreOptions(t *testing.T) { t.Log("create NON app-store type export options with default values") { - options := NewNonAppStoreOptions(MethodDevelopment, false) + options := NewNonAppStoreOptions(MethodDevelopment) require.Equal(t, MethodDevelopment, options.Method) require.Equal(t, CompileBitcodeDefault, options.CompileBitcode) require.Equal(t, EmbedOnDemandResourcesAssetPacksInBundleDefault, options.EmbedOnDemandResourcesAssetPacksInBundle) @@ -263,7 +263,7 @@ func TestNonNewAppStoreOptions(t *testing.T) { func TestNonAppStoreOptionsToHash(t *testing.T) { t.Log("default NON app-store type options creates hash with method") { - options := NewNonAppStoreOptions(MethodDevelopment, false) + options := NewNonAppStoreOptions(MethodDevelopment) hash := options.Hash() require.Equal(t, 1, len(hash)) @@ -276,7 +276,7 @@ func TestNonAppStoreOptionsToHash(t *testing.T) { t.Log("custom NON app-store type option's generated hash contains all properties") { - options := NewNonAppStoreOptions(MethodEnterprise, false) + options := NewNonAppStoreOptions(MethodEnterprise) options.TeamID = "123" options.CompileBitcode = false options.EmbedOnDemandResourcesAssetPacksInBundle = false @@ -364,7 +364,7 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewNonAppStoreOptions(MethodEnterprise, false) + options := NewNonAppStoreOptions(MethodEnterprise) require.NoError(t, options.WriteToFile(pth)) content, err := fileutil.ReadStringFromFile(pth) @@ -386,7 +386,7 @@ func TestNonAppStoreOptionsWriteToFile(t *testing.T) { require.NoError(t, err) pth := filepath.Join(tmpDir, "exportOptions.plist") - options := NewNonAppStoreOptions(MethodEnterprise, false) + options := NewNonAppStoreOptions(MethodEnterprise) options.TeamID = "123" options.CompileBitcode = false options.EmbedOnDemandResourcesAssetPacksInBundle = false From c20da42522a3cd5105d81b3fb95dac121501fff8 Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:28:35 +0200 Subject: [PATCH 5/7] Better naming --- export/mac.go | 2 +- exportoptions/properties.go | 8 ++++---- exportoptions/properties_test.go | 12 ++++++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/export/mac.go b/export/mac.go index 1706d76d..e3fcd42d 100644 --- a/export/mac.go +++ b/export/mac.go @@ -44,7 +44,7 @@ func CreateMacCodeSignGroup(selectableGroups []SelectableCodeSignGroup, installe iosCodesignGroups := CreateIosCodeSignGroups(selectableGroups) for _, group := range iosCodesignGroups { - if exportMethod == exportoptions.MethodAppStore { + if exportMethod.IsAppStore() { installerCertificates := []certificateutil.CertificateInfoModel{} for _, installerCertificate := range installedInstallerCertificates { diff --git a/exportoptions/properties.go b/exportoptions/properties.go index b8cb9317..c3cf6d81 100644 --- a/exportoptions/properties.go +++ b/exportoptions/properties.go @@ -141,8 +141,8 @@ func ParseMethod(method string) (Method, error) { } } -// UpgradeExportMethod replaces the legacy export method strings with the ones available in Xcode 15.3 and later. -func UpgradeExportMethod(method Method) Method { +// UpgradeToXcode15_3MethodNames replaces the legacy export method strings with the ones available in Xcode 15.3 and later. +func UpgradeToXcode15_3MethodNames(method Method) Method { switch method { case MethodAppStore: return MethodAppStoreConnect @@ -150,9 +150,9 @@ func UpgradeExportMethod(method Method) Method { return MethodReleaseTesting case MethodDevelopment: return MethodDebugging + default: + return method } - - return method } // OnDemandResourcesAssetPacksBaseURLKey .... diff --git a/exportoptions/properties_test.go b/exportoptions/properties_test.go index 0e681dd6..04d57294 100644 --- a/exportoptions/properties_test.go +++ b/exportoptions/properties_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestUpgradeExportMethod(t *testing.T) { +func TestUpgradeToXcode15_3MethodNames(t *testing.T) { tests := []struct { name string method Method @@ -24,14 +24,22 @@ func TestUpgradeExportMethod(t *testing.T) { method: "development", want: "debugging", }, + { + method: "enterprise", + want: "enterprise", + }, { method: "developer-id", want: "developer-id", }, + { + method: "package", + want: "package", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, UpgradeExportMethod(tt.method)) + require.Equal(t, tt.want, UpgradeToXcode15_3MethodNames(tt.method)) }) } } From 92c6c09eda7904758519d6bc2352b078fee38ffe Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:29:50 +0200 Subject: [PATCH 6/7] Better name --- exportoptions/properties.go | 4 ++-- exportoptions/properties_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exportoptions/properties.go b/exportoptions/properties.go index c3cf6d81..86aaa72c 100644 --- a/exportoptions/properties.go +++ b/exportoptions/properties.go @@ -141,8 +141,8 @@ func ParseMethod(method string) (Method, error) { } } -// UpgradeToXcode15_3MethodNames replaces the legacy export method strings with the ones available in Xcode 15.3 and later. -func UpgradeToXcode15_3MethodNames(method Method) Method { +// UpgradeToXcode15_3MethodName replaces the legacy export method strings with the ones available in Xcode 15.3 and later. +func UpgradeToXcode15_3MethodName(method Method) Method { switch method { case MethodAppStore: return MethodAppStoreConnect diff --git a/exportoptions/properties_test.go b/exportoptions/properties_test.go index 04d57294..f3b3ca95 100644 --- a/exportoptions/properties_test.go +++ b/exportoptions/properties_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestUpgradeToXcode15_3MethodNames(t *testing.T) { +func TestUpgradeToXcode15_3MethodName(t *testing.T) { tests := []struct { name string method Method @@ -39,7 +39,7 @@ func TestUpgradeToXcode15_3MethodNames(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, UpgradeToXcode15_3MethodNames(tt.method)) + require.Equal(t, tt.want, UpgradeToXcode15_3MethodName(tt.method)) }) } } From 61e77f7b0f325684be537991d5cb3461004f99ea Mon Sep 17 00:00:00 2001 From: LaszloP <7979773+lpusok@users.noreply.github.com> Date: Mon, 7 Apr 2025 17:01:39 +0200 Subject: [PATCH 7/7] Fix: --- exportoptions/appstore_options.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/exportoptions/appstore_options.go b/exportoptions/appstore_options.go index 99fc38b1..94ecda26 100644 --- a/exportoptions/appstore_options.go +++ b/exportoptions/appstore_options.go @@ -30,13 +30,7 @@ type AppStoreOptionsModel struct { // NewAppStoreOptions sets "app-store" as the export method // deprecated: use NewAppStoreConnectOptions instead func NewAppStoreOptions() AppStoreOptionsModel { - return AppStoreOptionsModel{ - Method: MethodAppStore, - UploadBitcode: UploadBitcodeDefault, - UploadSymbols: UploadSymbolsDefault, - ManageAppVersion: manageAppVersionDefault, - TestFlightInternalTestingOnly: TestFlightInternalTestingOnlyDefault, - } + return NewAppStoreConnectOptions(MethodAppStore) } // NewAppStoreConnectOptions sets either "app-store" or "app-store-connect" as the export method