Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action][spm] add simulator flag for swift compiler #21707

Merged
merged 17 commits into from Dec 19, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion fastlane/lib/fastlane/actions/spm.rb
Expand Up @@ -10,6 +10,20 @@ def self.run(params)
cmd << "--configuration #{params[:configuration]}" if params[:configuration]
cmd << "--disable-sandbox" if params[:disable_sandbox]
cmd << "--verbose" if params[:verbose]
if params[:simulator]
# Check if the simulator syntax is correct using a regular expression
unless params[:simulator] =~ /^(iphone|macos)simulator(\d+\.\d+)?$/
UI.error("Invalid simulator syntax. Please use 'iphonesimulator', or 'macossimulator'.")
return
end
simulator_flags = [
"-Xswiftc", "-sdk",
"-Xswiftc", "$(xcrun --sdk #{params[:simulator]} --show-sdk-path)",
"-Xswiftc", "-target",
"-Xswiftc", "x86_64-apple-ios$(xcrun --sdk #{params[:simulator]} --show-sdk-version | cut -d '.' -f 1)-simulator"
rogerluan marked this conversation as resolved.
Show resolved Hide resolved
]
cmd += simulator_flags
end
cmd << params[:command] if package_commands.include?(params[:command])
cmd << "--enable-code-coverage" if params[:enable_code_coverage] && (params[:command] == 'generate-xcodeproj' || params[:command] == 'test')
if params[:xcconfig]
Expand Down Expand Up @@ -93,7 +107,12 @@ def self.available_options
env_name: "FL_SPM_VERBOSE",
description: "Increase verbosity of informational output",
type: Boolean,
default_value: false)
default_value: false),
FastlaneCore::ConfigItem.new(key: :simulator,
env_name: "FL_SPM_SIMULATOR",
description: "Specifies the simulator to pass for Swift Compiler",
gharary marked this conversation as resolved.
Show resolved Hide resolved
type: String,
optional: true)
]
end

Expand Down