1

Some of the builds in our environment are failing because the builds are using a 13.X iOS/tvOS simulator and for some reason that causes issues. I made changes to our Fastfile so that the builds use a 14.2 simulator instead and now the builds are succeeding.

Here are the changes I made to the fast file.

First, I declared a dict:

XCODE_DESTINATION = {
  iphoneos: "generic/platform=iOS",
  iphonesimulator: "platform=iOS Simulator,OS=14.2,name=iPhone 11 Pro Max",
  appletvos: "generic/platform=tvOS",
  appletvsimulator: "platform=tvOS Simulator,OS=14.2,name=Apple TV 4K"
}

Then, in the run_tests lane for both iOS and tvOS, I reference the iphonesimulator and the appletvsimulator:

    run_tests(
      destination: XCODE_DESTINATION[:iphonesimulator],
      workspace: WORKSPACE_NAME,
      scheme: options[:scheme_tests]
    )
    run_tests(
      destination: XCODE_DESTINATION[:appletvsimulator],
      workspace: WORKSPACE_NAME,
      scheme: options[:scheme_tests]
    )

Even though this solution solves the problem, I don't really want the XCODE_DESTINATION dict to have to specifically reference an OS version and a specific device.

Is there a way I can configure this Fastfile so that it runs the tests only if a 14.X simulator is present within XCode without having to specifically indicate that in the dict?

Thank you!

JFortYork
  • 137
  • 10

1 Answers1

2

Currently fastlane does not support this, so feel free to create an issue -> https://github.com/fastlane/fastlane/issues

But you can specify the simulators and versions in the run_tests:

run_tests(
      devices: ['iPhone 11 Pro Max (14.2)'],
      workspace: WORKSPACE_NAME,
      scheme: options[:scheme_tests],
      ensure_devices_found: true
    )

Additionally you can set ensure_devices_found to true, so if the specified simulator(s) not found, tests will fail.