Skip to content

Commit

Permalink
Add -packageAuthorizationProvider flag for xcodebuild (fastlane#22227)
Browse files Browse the repository at this point in the history
* add package_authorization_provider argument to xcodebuild

* add documentation for packageAuthorizationProvider, fix failing test for visionOS

* fix typo

* fix visionOS tests

* Update snapshot/lib/snapshot/options.rb

Co-authored-by: iulianOnofrei (U-lee-aan) <[email protected]>

* added verify block for package authorization provider argument

---------

Co-authored-by: iulianOnofrei (U-lee-aan) <[email protected]>
  • Loading branch information
yarneo and revolter authored Sep 26, 2024
1 parent b61548c commit b0f4b18
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 11 deletions.
45 changes: 36 additions & 9 deletions fastlane/swift/Fastlane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
- skipPackageDependenciesResolution: Skips resolution of Swift Package Manager dependencies
- disablePackageAutomaticUpdates: Prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: The absolute path to the generated ipa file

Expand Down Expand Up @@ -1448,6 +1449,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
let skipPackageDependenciesResolutionArg = skipPackageDependenciesResolution.asRubyArgument(name: "skip_package_dependencies_resolution", type: nil)
let disablePackageAutomaticUpdatesArg = disablePackageAutomaticUpdates.asRubyArgument(name: "disable_package_automatic_updates", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
schemeArg,
Expand Down Expand Up @@ -1497,7 +1499,8 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
clonedSourcePackagesPathArg,
skipPackageDependenciesResolutionArg,
disablePackageAutomaticUpdatesArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -1556,6 +1559,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
- skipPackageDependenciesResolution: Skips resolution of Swift Package Manager dependencies
- disablePackageAutomaticUpdates: Prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: The absolute path to the generated ipa file

Expand Down Expand Up @@ -1656,6 +1660,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
let skipPackageDependenciesResolutionArg = skipPackageDependenciesResolution.asRubyArgument(name: "skip_package_dependencies_resolution", type: nil)
let disablePackageAutomaticUpdatesArg = disablePackageAutomaticUpdates.asRubyArgument(name: "disable_package_automatic_updates", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
schemeArg,
Expand Down Expand Up @@ -1702,7 +1707,8 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
clonedSourcePackagesPathArg,
skipPackageDependenciesResolutionArg,
disablePackageAutomaticUpdatesArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -1762,6 +1768,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
- skipPackageDependenciesResolution: Skips resolution of Swift Package Manager dependencies
- disablePackageAutomaticUpdates: Prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: The absolute path to the generated ipa file

Expand Down Expand Up @@ -1864,6 +1871,7 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
let skipPackageDependenciesResolutionArg = skipPackageDependenciesResolution.asRubyArgument(name: "skip_package_dependencies_resolution", type: nil)
let disablePackageAutomaticUpdatesArg = disablePackageAutomaticUpdates.asRubyArgument(name: "disable_package_automatic_updates", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
schemeArg,
Expand Down Expand Up @@ -1911,7 +1919,8 @@ public func buildAndroidApp(task: OptionalConfigValue<String?> = .fastlaneDefaul
clonedSourcePackagesPathArg,
skipPackageDependenciesResolutionArg,
disablePackageAutomaticUpdatesArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -2166,6 +2175,7 @@ public func captureAndroidScreenshots(androidHome: OptionalConfigValue<String?>
- disableXcpretty: Disable xcpretty formatting of build
- suppressXcodeOutput: Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)
*/
public func captureIosScreenshots(workspace: OptionalConfigValue<String?> = .fastlaneDefault(nil),
project: OptionalConfigValue<String?> = .fastlaneDefault(nil),
Expand Down Expand Up @@ -2266,6 +2276,7 @@ public func captureIosScreenshots(workspace: OptionalConfigValue<String?> = .fas
let disableXcprettyArg = disableXcpretty.asRubyArgument(name: "disable_xcpretty", type: nil)
let suppressXcodeOutputArg = suppressXcodeOutput.asRubyArgument(name: "suppress_xcode_output", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
xcargsArg,
Expand Down Expand Up @@ -2314,7 +2325,8 @@ public func captureIosScreenshots(workspace: OptionalConfigValue<String?> = .fas
xcprettyArgsArg,
disableXcprettyArg,
suppressXcodeOutputArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -2375,6 +2387,7 @@ public func captureIosScreenshots(workspace: OptionalConfigValue<String?> = .fas
- disableXcpretty: Disable xcpretty formatting of build
- suppressXcodeOutput: Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)
*/
public func captureScreenshots(workspace: OptionalConfigValue<String?> = .fastlaneDefault(nil),
project: OptionalConfigValue<String?> = .fastlaneDefault(nil),
Expand Down Expand Up @@ -2475,6 +2488,7 @@ public func captureScreenshots(workspace: OptionalConfigValue<String?> = .fastla
let disableXcprettyArg = disableXcpretty.asRubyArgument(name: "disable_xcpretty", type: nil)
let suppressXcodeOutputArg = suppressXcodeOutput.asRubyArgument(name: "suppress_xcode_output", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
xcargsArg,
Expand Down Expand Up @@ -2523,7 +2537,8 @@ public func captureScreenshots(workspace: OptionalConfigValue<String?> = .fastla
xcprettyArgsArg,
disableXcprettyArg,
suppressXcodeOutputArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -5692,6 +5707,7 @@ public func gradle(task: OptionalConfigValue<String?> = .fastlaneDefault(nil),
- skipPackageDependenciesResolution: Skips resolution of Swift Package Manager dependencies
- disablePackageAutomaticUpdates: Prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: The absolute path to the generated ipa file

Expand Down Expand Up @@ -5798,6 +5814,7 @@ public func gradle(task: OptionalConfigValue<String?> = .fastlaneDefault(nil),
let skipPackageDependenciesResolutionArg = skipPackageDependenciesResolution.asRubyArgument(name: "skip_package_dependencies_resolution", type: nil)
let disablePackageAutomaticUpdatesArg = disablePackageAutomaticUpdates.asRubyArgument(name: "disable_package_automatic_updates", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
schemeArg,
Expand Down Expand Up @@ -5847,7 +5864,8 @@ public func gradle(task: OptionalConfigValue<String?> = .fastlaneDefault(nil),
clonedSourcePackagesPathArg,
skipPackageDependenciesResolutionArg,
disablePackageAutomaticUpdatesArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -8854,6 +8872,7 @@ public func rubyVersion() {
- useSystemScm: Lets xcodebuild use system's scm configuration
- numberOfRetries: The number of times a test can fail
- failBuild: Should this step stop the build if the tests fail? Set this to false if you're using trainer
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: Outputs hash of results with the following keys: :number_of_tests, :number_of_failures, :number_of_retries, :number_of_tests_excluding_retries, :number_of_failures_excluding_retries

Expand Down Expand Up @@ -9016,6 +9035,7 @@ public func rubyVersion() {
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let numberOfRetriesArg = RubyCommand.Argument(name: "number_of_retries", value: numberOfRetries, type: nil)
let failBuildArg = failBuild.asRubyArgument(name: "fail_build", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
packagePathArg,
Expand Down Expand Up @@ -9093,7 +9113,8 @@ public func rubyVersion() {
disablePackageAutomaticUpdatesArg,
useSystemScmArg,
numberOfRetriesArg,
failBuildArg]
failBuildArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -9285,6 +9306,7 @@ public func say(text: [String],
- useSystemScm: Lets xcodebuild use system's scm configuration
- numberOfRetries: The number of times a test can fail
- failBuild: Should this step stop the build if the tests fail? Set this to false if you're using trainer
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)

- returns: Outputs hash of results with the following keys: :number_of_tests, :number_of_failures, :number_of_retries, :number_of_tests_excluding_retries, :number_of_failures_excluding_retries

Expand Down Expand Up @@ -9447,6 +9469,7 @@ public func say(text: [String],
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let numberOfRetriesArg = RubyCommand.Argument(name: "number_of_retries", value: numberOfRetries, type: nil)
let failBuildArg = failBuild.asRubyArgument(name: "fail_build", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
packagePathArg,
Expand Down Expand Up @@ -9524,7 +9547,8 @@ public func say(text: [String],
disablePackageAutomaticUpdatesArg,
useSystemScmArg,
numberOfRetriesArg,
failBuildArg]
failBuildArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down Expand Up @@ -10512,6 +10536,7 @@ public func slather(buildDirectory: OptionalConfigValue<String?> = .fastlaneDefa
- disableXcpretty: Disable xcpretty formatting of build
- suppressXcodeOutput: Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path
- useSystemScm: Lets xcodebuild use system's scm configuration
- packageAuthorizationProvider: Lets xcodebuild use a specified package authorization provider (keychain|netrc)
*/
public func snapshot(workspace: OptionalConfigValue<String?> = .fastlaneDefault(snapshotfile.workspace),
project: OptionalConfigValue<String?> = .fastlaneDefault(snapshotfile.project),
Expand Down Expand Up @@ -10612,6 +10637,7 @@ public func snapshot(workspace: OptionalConfigValue<String?> = .fastlaneDefault(
let disableXcprettyArg = disableXcpretty.asRubyArgument(name: "disable_xcpretty", type: nil)
let suppressXcodeOutputArg = suppressXcodeOutput.asRubyArgument(name: "suppress_xcode_output", type: nil)
let useSystemScmArg = useSystemScm.asRubyArgument(name: "use_system_scm", type: nil)
let packageAuthorizationProviderArg = packageAuthorizationProvider.asRubyArgument(name: "package_authorization_provider", type: nil)
let array: [RubyCommand.Argument?] = [workspaceArg,
projectArg,
xcargsArg,
Expand Down Expand Up @@ -10660,7 +10686,8 @@ public func snapshot(workspace: OptionalConfigValue<String?> = .fastlaneDefault(
xcprettyArgsArg,
disableXcprettyArg,
suppressXcodeOutputArg,
useSystemScmArg]
useSystemScmArg,
packageAuthorizationProviderArg]
let args: [RubyCommand.Argument] = array
.filter { $0?.value != nil }
.compactMap { $0 }
Expand Down
1 change: 1 addition & 0 deletions fastlane_core/lib/fastlane_core/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def xcodebuild_parameters
proj << "-derivedDataPath #{options[:derived_data_path].shellescape}" if options[:derived_data_path]
proj << "-xcconfig #{options[:xcconfig].shellescape}" if options[:xcconfig]
proj << "-scmProvider system" if options[:use_system_scm]
proj << "-packageAuthorizationProvider #{options[:package_authorization_provider].shellescape}" if options[:package_authorization_provider]

xcode_at_least_11 = FastlaneCore::Helper.xcode_at_least?('11.0')
if xcode_at_least_11 && options[:cloned_source_packages_path]
Expand Down
11 changes: 11 additions & 0 deletions fastlane_core/spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,17 @@ def count_processes(text)
end
end

describe "xcodebuild package_authorization_provider" do
it 'generates an xcodebuild -showBuildSettings command that includes package_authorization_provider if provided in options', requires_xcode: true do
project = FastlaneCore::Project.new({
project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj",
package_authorization_provider: "keychain"
})
command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -packageAuthorizationProvider keychain 2>&1"
expect(project.build_xcodebuild_showbuildsettings_command).to eq(command)
end
end

describe 'xcodebuild_xcconfig option', requires_xcode: true do
it 'generates an xcodebuild -showBuildSettings command without xcconfig by default' do
project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" })
Expand Down
11 changes: 10 additions & 1 deletion gym/lib/gym/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,16 @@ def self.plain_options
description: "Lets xcodebuild use system's scm configuration",
optional: true,
type: Boolean,
default_value: false)
default_value: false),
FastlaneCore::ConfigItem.new(key: :package_authorization_provider,
env_name: "GYM_PACKAGE_AUTHORIZATION_PROVIDER",
description: "Lets xcodebuild use a specified package authorization provider (keychain|netrc)",
optional: true,
type: String,
verify_block: proc do |value|
av = %w(netrc keychain)
UI.user_error!("Unsupported authorization provider '#{value}', must be: #{av}") unless av.include?(value)
end)
]
end
end
Expand Down
Loading

0 comments on commit b0f4b18

Please sign in to comment.