Skip to content

Commit 446a88c

Browse files
authored
Add new export methods (#265)
* Add new export methods
1 parent 6b912cd commit 446a88c

File tree

5 files changed

+118
-12
lines changed

5 files changed

+118
-12
lines changed

export/mac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func CreateMacCodeSignGroup(selectableGroups []SelectableCodeSignGroup, installe
4444
iosCodesignGroups := CreateIosCodeSignGroups(selectableGroups)
4545

4646
for _, group := range iosCodesignGroups {
47-
if exportMethod == exportoptions.MethodAppStore {
47+
if exportMethod.IsAppStore() {
4848
installerCertificates := []certificateutil.CertificateInfoModel{}
4949

5050
for _, installerCertificate := range installedInstallerCertificates {

exportoptions/appstore_options.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
// AppStoreOptionsModel ...
1010
type AppStoreOptionsModel struct {
11+
Method Method
1112
TeamID string
1213
BundleIDProvisioningProfileMapping map[string]string
1314
SigningCertificate string
@@ -26,9 +27,19 @@ type AppStoreOptionsModel struct {
2627
TestFlightInternalTestingOnly bool
2728
}
2829

29-
// NewAppStoreOptions ...
30+
// NewAppStoreOptions sets "app-store" as the export method
31+
// deprecated: use NewAppStoreConnectOptions instead
3032
func NewAppStoreOptions() AppStoreOptionsModel {
33+
return NewAppStoreConnectOptions(MethodAppStore)
34+
}
35+
36+
// NewAppStoreConnectOptions sets either "app-store" or "app-store-connect" as the export method
37+
func NewAppStoreConnectOptions(method Method) AppStoreOptionsModel {
38+
if !method.IsAppStore() {
39+
panic("non app-store method passed to NewAppStoreConnectOptions")
40+
}
3141
return AppStoreOptionsModel{
42+
Method: method,
3243
UploadBitcode: UploadBitcodeDefault,
3344
UploadSymbols: UploadSymbolsDefault,
3445
ManageAppVersion: manageAppVersionDefault,
@@ -39,7 +50,7 @@ func NewAppStoreOptions() AppStoreOptionsModel {
3950
// Hash ...
4051
func (options AppStoreOptionsModel) Hash() map[string]interface{} {
4152
hash := map[string]interface{}{}
42-
hash[MethodKey] = MethodAppStore
53+
hash[MethodKey] = options.Method
4354
if options.TeamID != "" {
4455
hash[TeamIDKey] = options.TeamID
4556
}

exportoptions/exportoptions_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ func TestManifestToHash(t *testing.T) {
105105
}
106106
}
107107

108-
func TestNewAppStoreOptions(t *testing.T) {
108+
func TestNewAppStoreConnectOptions(t *testing.T) {
109109
t.Log("create app-store type export options with default values")
110110
{
111-
options := NewAppStoreOptions()
111+
options := NewAppStoreConnectOptions(MethodAppStoreConnect)
112112
require.Equal(t, UploadBitcodeDefault, options.UploadBitcode)
113113
require.Equal(t, UploadSymbolsDefault, options.UploadSymbols)
114114
require.Equal(t, TestFlightInternalTestingOnlyDefault, options.TestFlightInternalTestingOnly)
115115
}
116116
}
117117

118118
func TestAppStoreOptionsToHash(t *testing.T) {
119-
t.Log("default app-store type options creates hash with method")
119+
t.Log("default app-store type options creates hash with legacy method")
120120
{
121121
options := NewAppStoreOptions()
122122
options.ManageAppVersion = true
@@ -130,6 +130,20 @@ func TestAppStoreOptionsToHash(t *testing.T) {
130130
}
131131
}
132132

133+
t.Log("default app-store type options creates hash with new method")
134+
{
135+
options := NewAppStoreConnectOptions(MethodAppStoreConnect)
136+
options.ManageAppVersion = true
137+
hash := options.Hash()
138+
require.Equal(t, 1, len(hash), fmt.Sprintf("Hash: %+v", hash))
139+
140+
{
141+
value, ok := hash[MethodKey]
142+
require.Equal(t, true, ok)
143+
require.Equal(t, MethodAppStoreConnect, value)
144+
}
145+
}
146+
133147
t.Log("custom app-store type option's generated hash contains all properties")
134148
{
135149
options := NewAppStoreOptions()
@@ -182,7 +196,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) {
182196
require.NoError(t, err)
183197
pth := filepath.Join(tmpDir, "exportOptions.plist")
184198

185-
options := NewAppStoreOptions()
199+
options := NewAppStoreConnectOptions(MethodAppStoreConnect)
186200
options.ManageAppVersion = true
187201
require.NoError(t, options.WriteToFile(pth))
188202

@@ -193,7 +207,7 @@ func TestAppStoreOptionsWriteToFile(t *testing.T) {
193207
<plist version="1.0">
194208
<dict>
195209
<key>method</key>
196-
<string>app-store</string>
210+
<string>app-store-connect</string>
197211
</dict>
198212
</plist>`
199213
require.Equal(t, desired, content)

exportoptions/properties.go

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,45 @@ const MethodKey = "method"
8383
type Method string
8484

8585
const (
86-
// MethodAppStore ...
86+
// MethodAppStore is deprecated since Xcode 15.3, its new name is MethodAppStoreConnect
8787
MethodAppStore Method = "app-store"
88-
// MethodAdHoc ...
88+
// MethodAdHoc is deprecated since Xcode 15.3, its new name is MethodReleaseTesting
8989
MethodAdHoc Method = "ad-hoc"
9090
// MethodPackage ...
9191
MethodPackage Method = "package"
9292
// MethodEnterprise ...
9393
MethodEnterprise Method = "enterprise"
94-
// MethodDevelopment ...
94+
// MethodDevelopment is deprecated since Xcode 15.3, its new name is MethodDebugging
9595
MethodDevelopment Method = "development"
9696
// MethodDeveloperID ...
9797
MethodDeveloperID Method = "developer-id"
98+
// MethodDebugging is the new name for MethodDevelopment since Xcode 15.3
99+
MethodDebugging Method = "debugging"
100+
// MethodAppStoreConnect is the new name for MethodAppStore since Xcode 15.3
101+
MethodAppStoreConnect Method = "app-store-connect"
102+
// MethodReleaseTesting is the new name for MethodAdHoc since Xcode 15.3
103+
MethodReleaseTesting Method = "release-testing"
98104
// MethodDefault ...
99105
MethodDefault Method = MethodDevelopment
100106
)
101107

102-
// ParseMethod ...
108+
func (m Method) IsAppStore() bool {
109+
return m == MethodAppStore || m == MethodAppStoreConnect
110+
}
111+
112+
func (m Method) IsAdHoc() bool {
113+
return m == MethodAdHoc || m == MethodReleaseTesting
114+
}
115+
116+
func (m Method) IsDevelopment() bool {
117+
return m == MethodDevelopment || m == MethodDebugging
118+
}
119+
120+
func (m Method) IsEnterprise() bool {
121+
return m == MethodEnterprise
122+
}
123+
124+
// ParseMethod parses Step input and returns the corresponding Method.
103125
func ParseMethod(method string) (Method, error) {
104126
switch method {
105127
case "app-store":
@@ -119,6 +141,20 @@ func ParseMethod(method string) (Method, error) {
119141
}
120142
}
121143

144+
// UpgradeToXcode15_3MethodName replaces the legacy export method strings with the ones available in Xcode 15.3 and later.
145+
func UpgradeToXcode15_3MethodName(method Method) Method {
146+
switch method {
147+
case MethodAppStore:
148+
return MethodAppStoreConnect
149+
case MethodAdHoc:
150+
return MethodReleaseTesting
151+
case MethodDevelopment:
152+
return MethodDebugging
153+
default:
154+
return method
155+
}
156+
}
157+
122158
// OnDemandResourcesAssetPacksBaseURLKey ....
123159
const OnDemandResourcesAssetPacksBaseURLKey = "onDemandResourcesAssetPacksBaseURL"
124160

exportoptions/properties_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package exportoptions
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestUpgradeToXcode15_3MethodName(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
method Method
13+
want Method
14+
}{
15+
{
16+
method: "app-store",
17+
want: "app-store-connect",
18+
},
19+
{
20+
method: "ad-hoc",
21+
want: "release-testing",
22+
},
23+
{
24+
method: "development",
25+
want: "debugging",
26+
},
27+
{
28+
method: "enterprise",
29+
want: "enterprise",
30+
},
31+
{
32+
method: "developer-id",
33+
want: "developer-id",
34+
},
35+
{
36+
method: "package",
37+
want: "package",
38+
},
39+
}
40+
for _, tt := range tests {
41+
t.Run(tt.name, func(t *testing.T) {
42+
require.Equal(t, tt.want, UpgradeToXcode15_3MethodName(tt.method))
43+
})
44+
}
45+
}

0 commit comments

Comments
 (0)