'Fastlane iOS: Keeps building for simulator when using "iphoneos" sdk

I'm attempting to write a fastlane script that zips and uploads my app and testplan to Firebase Test Lab. It is currently failing because it keeps building the app for a simulator instead of a real device. I have no idea why because with the sdk set to "iphoneos" this shouldn't be happening?

lane :QAUITests do |options|
  generate(options)
  
  @testplan = options[:testplan]
  
  scan(
    scheme: 'QAUITests',              # XCTest scheme
    clean: true,                      # Recommended: This would ensure the build would not include unnecessary files
    skip_detect_devices: true,        # Required
    build_for_testing: true,          # Required
    sdk: 'iphoneos',              # Required
    should_zip_build_products: true,  # Must be true to set the correct format for Firebase Test Lab
    buildlog_path: "./fastlane/fastlane-buildlog",
    configuration: 'Debug',
    derived_data_path: "./DerivedData",
    testplan: @testplan
  )

  sh "zip -r MyTests.zip build/Build/Products/* Debug-iphoneos QAUITests_Regression_iphoneos15.4-arm64.xctestrun"
  sh "gcloud firebase test ios run --test MyTests.zip --device model=iphone11pro,version=14.7,locale=en_GB,orientation=portrait"

For more context, this is what I'm trying to do https://firebase.google.com/docs/test-lab/ios/command-line. They do have a plugin to help but unfortunatly this issue prevents it from working https://github.com/fastlane/fastlane-plugin-firebase_test_lab/issues/79

enter image description here

Exit status of command 'zip -r MyTests.zip DerivedData/Build/Products/* Debug-iphoneos QAUITests_Regression_iphoneos15.4-arm64.xctestrun' was 12 instead of 0.
    zip warning: name not matched: DerivedData/Build/Products/*
    zip warning: name not matched: Debug-iphoneos
    zip warning: name not matched: QAUITests_Regression_iphoneos15.4-arm64.xctestrun


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source