Skip to content

Commit cc31aeb

Browse files
lpusokofalvai
andauthored
Support new export methods (#375)
Co-authored-by: Olivér Falvai <[email protected]>
1 parent 3871405 commit cc31aeb

File tree

15 files changed

+231
-73
lines changed

15 files changed

+231
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Build a development IPA with custom xcconfig file path:
123123
| --- | --- | --- | --- |
124124
| `project_path` | Xcode Project (`.xcodeproj`) or Workspace (`.xcworkspace`) path. The input value sets xcodebuild's `-project` or `-workspace` option. | required | `$BITRISE_PROJECT_PATH` |
125125
| `scheme` | Xcode Scheme name. The input value sets xcodebuild's `-scheme` option. | required | `$BITRISE_SCHEME` |
126-
| `distribution_method` | Describes how Xcode should export the archive. | required | `development` |
126+
| `distribution_method` | Describes how Xcode should export the archive. The input value sets the method in the export options plist content. Note: In Xcode 15.3, distribution methods have been renamed. The values of this input reflect the old names. When running with Xcode 15.3 and later, the new names are passed to `xcodebuild`: - `debugging`, when `development` is selected - `app-store-connect`, when `app-store` is selected - `release-testing`, when `ad-hoc` is selected - `enterprise` is unchanged | required | `development` |
127127
| `configuration` | Xcode Build Configuration. If not specified, the default Build Configuration will be used. The input value sets xcodebuild's `-configuration` option. | | |
128128
| `xcconfig_content` | Build settings to override the project's build settings, using xcodebuild's `-xcconfig` option. You can't define `-xcconfig` option in `Additional options for the xcodebuild command` if this input is set. If empty, no setting is changed. When set it can be either: 1. Existing `.xcconfig` file path. Example: `./ios-sample/ios-sample/Configurations/Dev.xcconfig` 2. The contents of a newly created temporary `.xcconfig` file. (This is the default.) Build settings must be separated by newline character (`\n`). Example: ``` COMPILER_INDEX_STORE_ENABLE = NO ONLY_ACTIVE_ARCH[config=Debug][sdk=*][arch=*] = YES ``` | | `COMPILER_INDEX_STORE_ENABLE = NO` |
129129
| `perform_clean_action` | If this input is set, `clean` xcodebuild action will be performed besides the `archive` action. | required | `no` |

e2e/bitrise.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ workflows:
3939
# - BITRISE_SCHEME: World
4040
# - CODE_SIGNING_METHOD: api-key
4141
# - MIN_DAYS_PROFILE_VALID: 0
42-
# - FORCE_CODE_SIGN_IDENTITY: "iPhone Developer: Tooling Bot Bitrise"
42+
# - FORCE_CODE_SIGN_IDENTITY: "Apple Development: Tooling Bot Bitrise"
4343
# - TEAM_ID: 72SA8V3WYL
4444
# - FORCE_PROV_PROFILE_SPECIFIER: ""
4545
# - IPA_EXPORT_METHOD: development
@@ -163,7 +163,7 @@ workflows:
163163
- automatic_code_signing: $CODE_SIGNING_METHOD
164164
- xcconfig_content: |
165165
COMPILER_INDEX_STORE_ENABLE = NO
166-
CODE_SIGN_IDENTITY = iPhone Developer: Tooling Bot Bitrise
166+
CODE_SIGN_IDENTITY = Apple Development: Tooling Bot Bitrise
167167
- distribution_method: $IPA_EXPORT_METHOD
168168
- icloud_container_environment: $IPA_EXPORT_ICLOUD_CONTAINER_ENVIRONMENT
169169
- export_development_team: $TEAM_ID
@@ -191,7 +191,7 @@ workflows:
191191
- CODE_SIGNING_METHOD: api-key
192192
- XCCONFIG_CONTENT: |
193193
COMPILER_INDEX_STORE_ENABLE = NO
194-
CODE_SIGN_IDENTITY = iPhone Developer: Tooling Bot Bitrise
194+
CODE_SIGN_IDENTITY = Apple Development: Tooling Bot Bitrise
195195
- MIN_DAYS_PROFILE_VALID: 0
196196
- IPA_EXPORT_METHOD: development
197197
- LOG_FORMATTER: xcodebuild
@@ -444,7 +444,7 @@ workflows:
444444
- BITRISE_SCHEME: Catalyst Sample
445445
- CODE_SIGNING_METHOD: api-key
446446
- MIN_DAYS_PROFILE_VALID: 0
447-
- FORCE_CODE_SIGN_IDENTITY: "iPhone Developer: Tooling Bot Bitrise"
447+
- FORCE_CODE_SIGN_IDENTITY: "Apple Development: Tooling Bot Bitrise"
448448
- TEAM_ID: 72SA8V3WYL
449449
- FORCE_PROV_PROFILE_SPECIFIER: ""
450450
- IPA_EXPORT_METHOD: development

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/bitrise-steplib/steps-xcode-archive
22

3-
go 1.22
3+
go 1.23.0
44

55
toolchain go1.23.5
66

@@ -9,7 +9,7 @@ require (
99
github.com/bitrise-io/go-utils v1.0.14
1010
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23
1111
github.com/bitrise-io/go-xcode v1.3.0
12-
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.55
12+
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.56
1313
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
1414
github.com/stretchr/testify v1.10.0
1515
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 h1:Dfh4nyZPuEtilBisidejqxBrkx9
1313
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23/go.mod h1:3XUplo0dOWc3DqT2XA2SeHToDSg7+j1y1HTHibT2H68=
1414
github.com/bitrise-io/go-xcode v1.3.0 h1:QB8Vyr2oZQro/ocs9DJai80rlYL1hU1kwjHqdGslFLo=
1515
github.com/bitrise-io/go-xcode v1.3.0/go.mod h1:9OwsvrhZ4A2JxHVoEY7CPcABAKA+OE7FQqFfBfvbFuY=
16-
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.55 h1:hLLVWstKv0KZZexCWE9so1mDB4MnDZK2TrX5jz2AYpI=
17-
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.55/go.mod h1:T4rhWQljdgH5As4Dq/RQWuazdScY0YB7uZAMuBUnxeY=
16+
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.56 h1:JSwOStu6HCkT6b7icTQ3x/0OBNPQ8mD7Q6vQt2hG7fg=
17+
github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.56/go.mod h1:zoLzT5fJE8V2SeYq0D0Z+ZN2FAzERjV3uiqDg5H8Bug=
1818
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
1919
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2020
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/bitrise-io/go-utils/v2/log"
1414
"github.com/bitrise-io/go-utils/v2/pathutil"
1515
"github.com/bitrise-io/go-xcode/v2/xcodecommand"
16+
"github.com/bitrise-io/go-xcode/v2/xcodeversion"
1617
"github.com/bitrise-steplib/steps-xcode-archive/step"
1718
)
1819

@@ -58,11 +59,11 @@ func run() int {
5859
func createConfigParser(logger log.Logger) step.XcodebuildArchiveConfigParser {
5960
envRepository := env.NewRepository()
6061
inputParser := stepconf.NewInputParser(envRepository)
61-
xcodeVersionProvider := step.NewXcodebuildXcodeVersionProvider()
6262
fileManager := fileutil.NewFileManager()
6363
cmdFactory := command.NewFactory(envRepository)
64+
xcodeVersionReader := xcodeversion.NewXcodeVersionProvider(cmdFactory)
6465

65-
return step.NewXcodeArchiveConfigParser(inputParser, xcodeVersionProvider, fileManager, cmdFactory, logger)
66+
return step.NewXcodeArchiveConfigParser(inputParser, xcodeVersionReader, fileManager, cmdFactory, logger)
6667
}
6768

6869
func createXcodebuildArchiver(logger log.Logger, logFormatter string) (step.XcodebuildArchiver, error) {
@@ -72,6 +73,7 @@ func createXcodebuildArchiver(logger log.Logger, logFormatter string) (step.Xcod
7273
pathModifier := pathutil.NewPathModifier()
7374
fileManager := fileutil.NewFileManager()
7475
cmdFactory := command.NewFactory(envRepository)
76+
xcodeVersionReader := xcodeversion.NewXcodeVersionProvider(cmdFactory)
7577

7678
xcodeCommandRunner := xcodecommand.Runner(nil)
7779
switch logFormatter {
@@ -92,7 +94,7 @@ func createXcodebuildArchiver(logger log.Logger, logFormatter string) (step.Xcod
9294
panic(fmt.Sprintf("Unknown log formatter: %s", logFormatter))
9395
}
9496

95-
return step.NewXcodebuildArchiver(xcodeCommandRunner, logFormatter, pathProvider, pathChecker, pathModifier, fileManager, cmdFactory, logger), nil
97+
return step.NewXcodebuildArchiver(xcodeCommandRunner, logFormatter, xcodeVersionReader, pathProvider, pathChecker, pathModifier, fileManager, cmdFactory, logger), nil
9698
}
9799

98100
func createRunOptions(config step.Config) step.RunOpts {

mocks/XcodeVersionReader.go

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

step.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ inputs:
9494
opts:
9595
title: Distribution method
9696
summary: Describes how Xcode should export the archive.
97+
description: |-
98+
Describes how Xcode should export the archive.
99+
100+
The input value sets the method in the export options plist content.
101+
102+
Note: In Xcode 15.3, distribution methods have been renamed. The values of this input reflect the old names. When running with Xcode 15.3 and later, the new names are passed to `xcodebuild`:
103+
- `debugging`, when `development` is selected
104+
- `app-store-connect`, when `app-store` is selected
105+
- `release-testing`, when `ad-hoc` is selected
106+
- `enterprise` is unchanged
97107
value_options:
98108
- development
99109
- app-store

step/step.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/bitrise-io/go-xcode/v2/xcconfig"
3333
cache "github.com/bitrise-io/go-xcode/v2/xcodecache"
3434
"github.com/bitrise-io/go-xcode/v2/xcodecommand"
35+
"github.com/bitrise-io/go-xcode/v2/xcodeversion"
3536
"github.com/bitrise-io/go-xcode/xcarchive"
3637
"github.com/bitrise-io/go-xcode/xcodebuild"
3738
"github.com/kballard/go-shellquote"
@@ -134,17 +135,18 @@ type Config struct {
134135
}
135136

136137
type XcodebuildArchiveConfigParser struct {
137-
stepInputParser stepconf.InputParser
138-
xcodeVersionProvider XcodeVersionProvider
139-
fileManager fileutil.FileManager
140-
cmdFactory command.Factory
141-
logger log.Logger
138+
stepInputParser stepconf.InputParser
139+
xcodeVersionReader xcodeversion.Reader
140+
fileManager fileutil.FileManager
141+
cmdFactory command.Factory
142+
logger log.Logger
142143
}
143144

144145
// XcodebuildArchiver ...
145146
type XcodebuildArchiver struct {
146147
xcodeCommandRunner xcodecommand.Runner
147148
logFormatter string
149+
xcodeVersionReader xcodeversion.Reader
148150
pathProvider pathutil.PathProvider
149151
pathChecker pathutil.PathChecker
150152
pathModifier pathutil.PathModifier
@@ -153,21 +155,22 @@ type XcodebuildArchiver struct {
153155
cmdFactory command.Factory
154156
}
155157

156-
func NewXcodeArchiveConfigParser(stepInputParser stepconf.InputParser, xcodeVersionProvider XcodeVersionProvider, fileManager fileutil.FileManager, cmdFactory command.Factory, logger log.Logger) XcodebuildArchiveConfigParser {
158+
func NewXcodeArchiveConfigParser(stepInputParser stepconf.InputParser, xcodeVersionReader xcodeversion.Reader, fileManager fileutil.FileManager, cmdFactory command.Factory, logger log.Logger) XcodebuildArchiveConfigParser {
157159
return XcodebuildArchiveConfigParser{
158-
stepInputParser: stepInputParser,
159-
xcodeVersionProvider: xcodeVersionProvider,
160-
fileManager: fileManager,
161-
cmdFactory: cmdFactory,
162-
logger: logger,
160+
stepInputParser: stepInputParser,
161+
xcodeVersionReader: xcodeVersionReader,
162+
fileManager: fileManager,
163+
cmdFactory: cmdFactory,
164+
logger: logger,
163165
}
164166
}
165167

166168
// NewXcodebuildArchiver ...
167-
func NewXcodebuildArchiver(xcodecommandRunner xcodecommand.Runner, logFormatter string, pathProvider pathutil.PathProvider, pathChecker pathutil.PathChecker, pathModifier pathutil.PathModifier, fileManager fileutil.FileManager, cmdFactory command.Factory, logger log.Logger) XcodebuildArchiver {
169+
func NewXcodebuildArchiver(xcodecommandRunner xcodecommand.Runner, logFormatter string, xcodeVersionReader xcodeversion.Reader, pathProvider pathutil.PathProvider, pathChecker pathutil.PathChecker, pathModifier pathutil.PathModifier, fileManager fileutil.FileManager, cmdFactory command.Factory, logger log.Logger) XcodebuildArchiver {
168170
return XcodebuildArchiver{
169171
xcodeCommandRunner: xcodecommandRunner,
170172
logFormatter: logFormatter,
173+
xcodeVersionReader: xcodeVersionReader,
171174
pathProvider: pathProvider,
172175
pathChecker: pathChecker,
173176
pathModifier: pathModifier,
@@ -222,17 +225,16 @@ func (s XcodebuildArchiveConfigParser) ProcessInputs() (Config, error) {
222225
s.logger.Infof("Xcode version:")
223226

224227
// Detect Xcode major version
225-
xcodebuildVersion, err := s.xcodeVersionProvider.GetXcodeVersion()
228+
xcodebuildVersion, err := s.xcodeVersionReader.GetVersion()
226229
if err != nil {
227230
return Config{}, fmt.Errorf("failed to determine xcode version, error: %s", err)
228231
}
229232
s.logger.Printf("%s (%s)", xcodebuildVersion.Version, xcodebuildVersion.BuildVersion)
230233

231-
xcodeMajorVersion := xcodebuildVersion.MajorVersion
232-
if xcodeMajorVersion < minSupportedXcodeMajorVersion {
233-
return Config{}, fmt.Errorf("invalid xcode major version (%d), should not be less then min supported: %d", xcodeMajorVersion, minSupportedXcodeMajorVersion)
234+
if xcodebuildVersion.Major < minSupportedXcodeMajorVersion {
235+
return Config{}, fmt.Errorf("invalid xcode major version (%d), should not be less then min supported: %d", xcodebuildVersion.Major, minSupportedXcodeMajorVersion)
234236
}
235-
config.XcodeMajorVersion = int(xcodeMajorVersion)
237+
config.XcodeMajorVersion = int(xcodebuildVersion.Major)
236238

237239
// Validation ExportOptionsPlistContent
238240
exportOptionsPlistContent := strings.TrimSpace(config.ExportOptionsPlistContent)
@@ -1003,9 +1005,9 @@ func (s XcodebuildArchiver) xcodeIPAExport(opts xcodeIPAExportOpts) (xcodeIPAExp
10031005
signingStyle = exportoptions.SigningStyleAutomatic
10041006
}
10051007

1006-
generator := exportoptionsgenerator.New(xcodeProj, scheme, configuration, s.logger)
1008+
generator := exportoptionsgenerator.New(xcodeProj, scheme, configuration, s.xcodeVersionReader, s.logger)
10071009
exportOptions, err := generator.GenerateApplicationExportOptions(exportMethod, opts.ICloudContainerEnvironment, opts.ExportDevelopmentTeam,
1008-
opts.UploadBitcode, opts.CompileBitcode, archiveCodeSignIsXcodeManaged, signingStyle, int64(opts.XcodeMajorVersion), opts.TestFlightInternalTestingOnly)
1010+
opts.UploadBitcode, opts.CompileBitcode, archiveCodeSignIsXcodeManaged, signingStyle, opts.TestFlightInternalTestingOnly)
10091011
if err != nil {
10101012
return out, err
10111013
}

step/step_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ func TestXcodeArchiveStep_ProcessInputs(t *testing.T) {
3636
t.Run(tt.name, func(t *testing.T) {
3737
envRepository := MockEnvRepository{envs: tt.envs}
3838
s := XcodebuildArchiveConfigParser{
39-
xcodeVersionProvider: NewMockXcodeVersionProvider(models.XcodebuildVersionModel{MajorVersion: 11}),
40-
stepInputParser: stepconf.NewInputParser(envRepository),
41-
logger: log.NewLogger(),
39+
stepInputParser: stepconf.NewInputParser(envRepository),
40+
logger: log.NewLogger(),
4241
}
4342

4443
config, err := s.ProcessInputs()

step/xcode_version_provider.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)