Skip to content

Commit

Permalink
[scan] run simulator destination with arch=x86_64 for Xcode 14.3 and …
Browse files Browse the repository at this point in the history
…up if on Intel (#21284)

* Added arch=x86_64 for scan

* Make as an option

* Only do for iOS
  • Loading branch information
joshdholtz committed May 17, 2023
1 parent 7b3e224 commit 586b13f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scan/lib/scan/detect_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,14 @@ def self.detect_destination
if Scan.building_mac_catalyst_for_mac?
Scan.config[:destination] = ["platform=macOS,variant=Mac Catalyst"]
elsif Scan.devices && Scan.devices.count > 0
Scan.config[:destination] = Scan.devices.map { |d| "platform=#{d.os_type} Simulator,id=#{d.udid}" }
# Explicitly run simulator in Rosetta (needed for Xcode 14.3 and up)
# Fixes https://github.com/fastlane/fastlane/issues/21194
arch = ""
if Scan.config[:run_rosetta_simulator]
arch = ",arch=x86_64"
end

Scan.config[:destination] = Scan.devices.map { |d| "platform=#{d.os_type} Simulator,id=#{d.udid}" + arch }
elsif Scan.project && Scan.project.mac_app?
Scan.config[:destination] = min_xcode8? ? ["platform=macOS"] : ["platform=OS X"]
end
Expand Down
5 changes: 5 additions & 0 deletions scan/lib/scan/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ def self.available_options
description: "Use only if you're a pro, use the other options instead",
is_string: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :run_rosetta_simulator,
env_name: "SCAN_RUN_ROSETTA_SIMULATOR",
description: "Adds arch=x86_64 to the xcodebuild 'destination' argument to run simulator in a Rosetta mode",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :catalyst_platform,
env_name: "SCAN_CATALYST_PLATFORM",
description: "Platform to build when using a Catalyst enabled app. Valid values are: ios, macos",
Expand Down
23 changes: 23 additions & 0 deletions scan/spec/detect_values_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@
expect(Scan.config[:destination].first).to match(/platform=macOS,variant=Mac Catalyst/)
end
end

context ":run_rosetta_simulator" do
it "adds arch=x86_64 if true", requires_xcodebuild: true do
options = { project: "./scan/examples/standard/app.xcodeproj", run_rosetta_simulator: true }
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
expect(Scan.config[:destination].first).to match(/platform=iOS/)
expect(Scan.config[:destination].first).to match(/,arch=x86_64/)
end

it "does not add arch=x86_64 if false", requires_xcodebuild: true do
options = { project: "./scan/examples/standard/app.xcodeproj", run_rosetta_simulator: false }
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
expect(Scan.config[:destination].first).to match(/platform=iOS/)
expect(Scan.config[:destination].first).to_not(match(/,arch=x86_64/))
end

it "does not add arch=x86_64 by default", requires_xcodebuild: true do
options = { project: "./scan/examples/standard/app.xcodeproj" }
Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)
expect(Scan.config[:destination].first).to match(/platform=iOS/)
expect(Scan.config[:destination].first).to_not(match(/,arch=x86_64/))
end
end
end

describe "validation" do
Expand Down

0 comments on commit 586b13f

Please sign in to comment.