fastlane: fastlane scan with `--run_rosetta_simulator` selects the wrong simulator

New Issue Checklist

Issue Description

fastlane scan with --run_rosetta_simulator selects the wrong simulator when using --run_rosetta_simulator.

I’m using the changes from this PR https://github.com/fastlane/fastlane/pull/21284

gem "fastlane", :git => "https://github.com/fastlane/fastlane.git", :ref => "586b13f72ee21b5dcac26241435425614bde475c"

A special XCTestCase was added that fails with a text corresponding to the simulators iOS version. When using --run_rosetta_simulator is specified, the selected simulator is the iPhone 11, iOS 16.4. Not the iPhone 12, iOS 15.5

final class FastlaneTests: XCTestCase {
    func testFastlaneScan() {
        if #available(iOS 16, *) {
            XCTFail("iOS 16")
        } else if #available(iOS 15, *) {
            XCTFail("iOS 15")
        } else {
            XCTFail("Other iOS")
        }
    }
}
Command executed
bundle exec fastlane scan --clean --workspace  USDK.xcworkspace --scheme USDK --force_quit_simulator --skip_build --device "iPhone 12" --run_rosetta_simulator --only_testing USDKTests/FastlaneTests/testFastlaneScan
Complete output when running fastlane, including the stack trace and command used

Listed destinations

[21:25:32]: ▸ 2023-05-19 21:25:32.681 xcodebuild[70435:759037] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
[21:26:03]: ▸ --- xcodebuild: WARNING: Using the first of multiple matching destinations:
[21:26:03]: ▸ { platform:iOS Simulator, id:DA521529-88CC-4C71-960C-680FB6A23AAD, OS:16.4, name:iPhone 11 }
[21:26:03]: ▸ { platform:iOS Simulator, id:F5E604EC-BDD1-4AF3-BC7A-46B62A758232, OS:15.5, name:iPhone 12 }

XCTest result:

[21:27:46]: ▸ Selected tests
[21:27:46]: ▸ Test Suite UNextSDKTests.xctest started
[21:27:46]: ▸ FastlaneTests
[21:27:46]: ▸     ✗ testFastlaneScan, failed - iOS 16
[21:27:46]: ▸ UNextSDKTests.FastlaneTests
[21:27:46]: ▸   testFastlaneScan, failed - iOS 16
[21:27:46]: ▸   /Users/h-anders/Development/git-repos/iOS_repos/iOS4/iOS_SDK/UNextSDKTests/Model/AccountInfo/UNAccountInfoTests.swift:15
[21:27:46]: ▸   ```
[21:27:46]: ▸         if #available(iOS 16, *) {
[21:27:46]: ▸             XCTFail("iOS 16")
[21:27:46]: ▸         } else if #available(iOS 15, *) {
[21:27:46]: ▸   ```
[21:27:46]: ▸ 	 Executed 1 test, with 1 failure (0 unexpected) in 0.497 (0.502) seconds
[21:27:46]: ▸

As can be seen from the test result, the iPhone 11 simulator is selected even though iPhone 12 is specified.

Environment

✅ fastlane environment ✅

Stack

Key Value
OS 13.4
Ruby 2.6.10
Bundler? true
Git git version 2.40.1
Installation Source ~/Development/git-repos/iOS_repos/iOS4/iOS_SDK/vendor/bundle/ruby/2.6.0/bin/fastlane
Host macOS 13.4 (22F66)
Ruby Lib Dir /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
OpenSSL Version LibreSSL 3.3.6
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode-14.3.1.app/Contents/Developer/
Xcode Version 14.3.1
Swift Version 5.8.1

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8
LANGUAGE

fastlane files:

No Fastfile found

No Appfile found

fastlane gems

Gem Version Update-Status
fastlane 2.212.2 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.3.0
bundler 2.1.4
rake 13.0.6
rexml 3.2.5
CFPropertyList 3.0.4
concurrent-ruby 1.2.2
i18n 1.13.0
minitest 5.18.0
tzinfo 2.0.6
zeitwerk 2.6.8
activesupport 6.1.7.3
public_suffix 4.0.6
addressable 2.8.0
httpclient 2.8.3
json 2.5.1
algoliasearch 1.27.5
artifactory 3.0.15
atomos 0.1.3
aws-eventstream 1.2.0
aws-partitions 1.766.0
aws-sigv4 1.5.2
jmespath 1.6.2
aws-sdk-core 3.173.0
aws-sdk-kms 1.64.0
aws-sdk-s3 1.122.0
babosa 1.0.4
claide 1.0.3
colored2 3.1.2
cork 0.3.0
nap 1.1.0
open4 1.3.4
claide-plugins 0.9.2
fuzzy_match 2.0.4
netrc 0.11.0
ffi 1.15.5
ethon 0.16.0
typhoeus 1.4.0
cocoapods-core 1.12.1
cocoapods-deintegrate 1.0.5
cocoapods-downloader 1.6.3
cocoapods-plugins 1.0.0
cocoapods-search 1.0.1
cocoapods-trunk 1.6.0
cocoapods-try 1.2.0
escape 0.0.4
fourflusher 2.3.1
gh_inspector 1.1.3
molinillo 0.8.0
ruby-macho 2.5.1
nanaimo 0.3.0
xcodeproj 1.21.0
cocoapods 1.12.1
colored 1.2
highline 2.0.3
commander 4.6.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
multipart-post 2.0.0
ruby2_keywords 0.0.5
faraday 1.8.0
faraday-http-cache 2.2.0
rchardet 1.8.0
git 1.13.1
kramdown 2.3.1
kramdown-parser-gfm 1.1.0
no_proxy_fix 0.1.2
sawyer 0.8.2
octokit 4.21.0
unicode-display_width 1.8.0
terminal-table 1.8.0
danger 8.4.2
thor 0.20.3
danger-swiftlint 0.29.4
declarative 0.0.20
digest-crc 0.6.4
unf_ext 0.0.8.2
unf 0.1.4
domain_name 0.5.20190701
dotenv 2.8.1
emoji_regex 3.2.3
excon 0.99.0
http-cookie 1.0.5
faraday-cookie_jar 0.0.7
faraday_middleware 1.2.0
fastimage 2.2.6
jwt 2.7.0
memoist 0.16.2
multi_json 1.15.0
os 1.1.4
signet 0.17.0
googleauth 1.5.2
mini_mime 1.1.2
trailblazer-option 0.1.2
uber 0.1.0
representable 3.2.0
retriable 3.1.2
webrick 1.8.1
google-apis-core 0.11.0
google-apis-androidpublisher_v3 0.42.0
google-apis-playcustomapp_v1 0.13.0
google-apis-iamcredentials_v1 0.17.0
google-apis-storage_v1 0.19.0
google-cloud-env 1.6.0
google-cloud-errors 1.3.1
google-cloud-core 1.6.0
google-cloud-storage 1.44.0
mini_magick 4.12.0
naturally 2.2.1
optparse 0.1.1
plist 3.7.0
rubyzip 2.3.2
security 0.1.3
simctl 1.6.10
terminal-notifier 2.0.0
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1

generated on: 2023-05-19

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 26 (10 by maintainers)

Most upvoted comments

@rogerluan In your first screenshot the specified destination is -destination 'platform=iOS Simulator, id=2C265EE3-6572-458F-BBD3-98C0285658B0,arch=x86_64'.

If you remove the arch=x86_64. I think it works.

So what i did (as @bartlomiejswierad-vodeno pointed out) was to to change the Architectures in the project to have ARCHS[sdk=iphonesimulator*] = x86_64 and then invoke fastlane without --run_rosetta_simulator.

(or xcodebuild by specifying only id : -destination 'platform=iOS Simulator,id=2C265EE3-6572-458F-BBD3-98C0285658B0')


I noticed that 2.213.0 is now released…

Same issue with picking the wrong simulator even with the correct id. If it’s not an issue with fastlane, do we have any issue opened for xcodebuild?

I opened FB12195073 on May 20 but don’t really expect to get any answers.

Maybe someone will have some luck in a WWDC lab or something.

@Kirikami xcodebuild is Xcode’s CLI, thus owned by Apple, closed source. There’s no public issue-tracking system for Xcode or xcodebuild, but anyone can open a radar with Apple directly

@rogerluan Well, I fixed it locally by setting Architectures in the project setting to x86_64 for iOS Simulator. It works for my project.

Also, I just spent whole day on it yesterday, so I just tried everything to make it work because deadline for us to migrate CI build to M1 is close.

@nevil If you sent the logs from the demo project you created, then it work for me. I even added some validation code to be 100% sure. This would not compile for other architecture.

#if arch(x86_64) || !targetEnvironment(simulator)
    #warning("This is good")
#else
    #error("Not valid arch")
#endif

Also I realized that picking destination by name and OS doesn’t work as expected. But when I picked it by id it worked well. (that is what fastlane does)

Command (I don’t have iPhone 12 configured, so I used 13 on purpose):

>  xcodebuild ARCHS=x86_64 -workspace RosettaTest.xcworkspace -scheme RosettaTest -destination 'platform=iOS Simulator,id=9BFDD8E5-C0D2-4884-AC09-897EA9AD125F' test

2023-05-25 08:09:56.209 xcodebuild[78441:22582151] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild ARCHS=x86_64 -workspace RosettaTest.xcworkspace -scheme RosettaTest -destination "platform=iOS Simulator,id=9BFDD8E5-C0D2-4884-AC09-897EA9AD125F" test

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line:
    ARCHS = x86_64

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:9BFDD8E5-C0D2-4884-AC09-897EA9AD125F, OS:15.5, name:iPhone 13 }
{ platform:iOS Simulator, id:9BFDD8E5-C0D2-4884-AC09-897EA9AD125F, OS:15.5, name:iPhone 13 }
Prepare packages

I have tested your sample code and I get the same issue you’re seeing: the first simulator is used. In my case specifically, though, the first simulator happens to be an iPad on iOS 15.5, so the test pass, but it’s by mere luck. Also, I isolated this issue outside of fastlane, to show it’s related to xcodebuild:

See last line of the log:

image

Also, I tested my suggestion here about using e.g. -destination 'platform=iOS Simulator,device=iPhone SE (3rd generation),OS=15.5,arch=x86_64' instead, but that didn’t help either:

image

I’m having the same issue, and as a result my tests fail due to the following issue:

Signing for "ModuleTests" requires a development team. Select a development team in the Signing & Capabilities editor.

It looks like the Mac Catalyst simulator is selected although the correct id is passed.