|
15 | 15 | # Uncomment the line if you want fastlane to automatically update itself |
16 | 16 | # update_fastlane |
17 | 17 |
|
| 18 | +# Workaround: Fastlane parses the OS version from `simctl list devices` section |
| 19 | +# headers (e.g., "iOS 26.3") and passes it as the xcodebuild destination OS. |
| 20 | +# But xcodebuild reports the full runtime version (e.g., 26.3.1), so the |
| 21 | +# name+OS destination match fails. Using the device UDID avoids this entirely. |
| 22 | +require "snapshot/test_command_generator" |
| 23 | +Snapshot::TestCommandGenerator.class_eval do |
| 24 | + class << self |
| 25 | + def destination(devices) |
| 26 | + unless verify_devices_share_os(devices) |
| 27 | + UI.user_error!("All devices provided to snapshot should run the same operating system") |
| 28 | + end |
| 29 | + return ["-destination 'platform=macOS'"] if devices.first.to_s =~ /^Mac/ |
| 30 | + |
| 31 | + case devices.first.to_s |
| 32 | + when /^Apple TV/ then os = "tvOS" |
| 33 | + when /^Apple Watch/ then os = "watchOS" |
| 34 | + else os = "iOS" |
| 35 | + end |
| 36 | + |
| 37 | + os_version = Snapshot.config[:ios_version] || Snapshot::LatestOsVersion.version(os) |
| 38 | + |
| 39 | + destinations = devices.map do |d| |
| 40 | + device = find_device(d, os_version) |
| 41 | + UI.user_error!("No device found named '#{d}' for version '#{os_version}'") if device.nil? |
| 42 | + if device.os_version != os_version |
| 43 | + UI.important("Using device named '#{device.name}' with version '#{device.os_version}' because no match was found for version '#{os_version}'") |
| 44 | + end |
| 45 | + "-destination 'platform=#{os} Simulator,id=#{device.udid}'" |
| 46 | + end |
| 47 | + |
| 48 | + return [destinations.join(" ")] |
| 49 | + end |
| 50 | + end |
| 51 | +end |
| 52 | + |
18 | 53 | default_platform :ios |
19 | 54 |
|
20 | 55 | platform :ios do |
|
0 commit comments