Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not launch "RunnerUITests" (OSStatus error -10661.) #2003

Open
bartekpacia opened this issue Dec 11, 2023 · 15 comments
Open

Could not launch "RunnerUITests" (OSStatus error -10661.) #2003

bartekpacia opened this issue Dec 11, 2023 · 15 comments
Labels
bug Something isn't working P1 High-priority issues at the top of the work list package: patrol_cli Related to the patrol_cli package package: patrol Related to the patrol package (native automation, test bundling)

Comments

@bartekpacia
Copy link
Contributor

bartekpacia commented Dec 11, 2023

I am unable to run tests on latest master branch (9f5cb3d). I'm getting very weird errors that I am unable to resolve.

I run:

  • patrol test -t integration_test/main_test.dart -v in packages/patrol/example
  • patrol test -t integration_test/example_test.dart -v in dev/e2e_app

I tried:

  • removing, re-cloning the repo
  • clearing DerivedData directory rm -rf ~/Library/Developer/Xcode/DerivedData/*
  • clearing app's build directory
  • restarting computer
Logs
$ xcodebuild test-without-building -xctestrun /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_integ/Build/Products/Runner_TestPlan_iphonesimulator17.0-arm64-x86_64.xctestrun -only-testing RunnerUITests -destination platform=iOS Simulator,name=iPhone 15 -resultBundlePath /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult
	Command line invocation:
	    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild test-without-building -xctestrun /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_integ/Build/Products/Runner_TestPlan_iphonesimulator17.0-arm64-x86_64.xctestrun -only-testing RunnerUITests -destination "platform=iOS Simulator,name=iPhone 15" -resultBundlePath /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult

	User defaults from command line:
	    IDEBuildOperationResultBundlePath = /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult
	    IDEPackageSupportUseBuiltinSCM = YES

	Writing result bundle at path:
		/Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult

	--- xcodebuild: WARNING: Using the first of multiple matching destinations:
	{ platform:macOS, arch:arm64e, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:x86_64, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64e, variant:Mac Catalyst, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64, variant:Mac Catalyst, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:x86_64, variant:Mac Catalyst, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64e, variant:DriverKit, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64, variant:DriverKit, id:00008103-000C258C0EBB001E }
	{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-000C258C0EBB001E }
	{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
	{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
	{ platform:macOS, name:Any Mac }
	{ platform:macOS, variant:Mac Catalyst, name:Any Mac }
	{ platform:tvOS, id:dvtdevice-DVTiOSDevicePlaceholder-appletvos:placeholder, name:Any tvOS Device }
	{ platform:tvOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-appletvsimulator:placeholder, name:Any tvOS Simulator Device }
	{ platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }
	{ platform:watchOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-watchsimulator:placeholder, name:Any watchOS Simulator Device }
	{ platform:iOS Simulator, id:7F715B15-1747-43BE-91ED-DFF46CCB7F8A, OS:17.0.1, name:iPad (10th generation) }
	{ platform:iOS Simulator, id:7F715B15-1747-43BE-91ED-DFF46CCB7F8A, OS:17.0.1, name:iPad (10th generation) }
	{ platform:iOS Simulator, id:4BF16D73-5A86-4C46-8734-AB31E296FBBC, OS:17.0.1, name:iPad Air (5th generation) }
	{ platform:iOS Simulator, id:4BF16D73-5A86-4C46-8734-AB31E296FBBC, OS:17.0.1, name:iPad Air (5th generation) }
	{ platform:iOS Simulator, id:B2432105-8161-4013-AF08-496F26452B6C, OS:17.0.1, name:iPad Pro (11-inch) (4th generation) }
	{ platform:iOS Simulator, id:B2432105-8161-4013-AF08-496F26452B6C, OS:17.0.1, name:iPad Pro (11-inch) (4th generation) }
	{ platform:iOS Simulator, id:329EA370-1B14-4B52-849A-D2D21F38D07F, OS:17.0.1, name:iPad Pro (12.9-inch) (6th generation) }
	{ platform:iOS Simulator, id:329EA370-1B14-4B52-849A-D2D21F38D07F, OS:17.0.1, name:iPad Pro (12.9-inch) (6th generation) }
	{ platform:iOS Simulator, id:8CB87DC5-1846-49AA-9DC8-1D529815CE9B, OS:17.0.1, name:iPad mini (6th generation) }
	{ platform:iOS Simulator, id:8CB87DC5-1846-49AA-9DC8-1D529815CE9B, OS:17.0.1, name:iPad mini (6th generation) }
	{ platform:iOS Simulator, id:14F71B6C-42E4-4312-9230-2CB2828CCBFE, OS:17.0.1, name:iPhone 15 }
	{ platform:iOS Simulator, id:14F71B6C-42E4-4312-9230-2CB2828CCBFE, OS:17.0.1, name:iPhone 15 }
	{ platform:iOS Simulator, id:74447F48-37AC-4DCA-AE0A-D8BAF7FD2090, OS:17.0.1, name:iPhone 15 }
	{ platform:iOS Simulator, id:74447F48-37AC-4DCA-AE0A-D8BAF7FD2090, OS:17.0.1, name:iPhone 15 }
	{ platform:iOS Simulator, id:69B2F2BB-44C4-48C1-903F-40475090C1AE, OS:17.0.1, name:iPhone 15 Plus }
	{ platform:iOS Simulator, id:69B2F2BB-44C4-48C1-903F-40475090C1AE, OS:17.0.1, name:iPhone 15 Plus }
	{ platform:iOS Simulator, id:ED9FC97A-B7E6-4BBB-BE41-5D12E94C6332, OS:17.0.1, name:iPhone 15 Pro }
	{ platform:iOS Simulator, id:ED9FC97A-B7E6-4BBB-BE41-5D12E94C6332, OS:17.0.1, name:iPhone 15 Pro }
	{ platform:iOS Simulator, id:2279BFB8-D2DB-4680-8B70-26A8F9F6114F, OS:17.0.1, name:iPhone 15 Pro Max }
	{ platform:iOS Simulator, id:2279BFB8-D2DB-4680-8B70-26A8F9F6114F, OS:17.0.1, name:iPhone 15 Pro Max }
	{ platform:iOS Simulator, id:BF7AADBE-7D77-43E7-9F65-91EE4F0AE20D, OS:17.0.1, name:iPhone SE (3rd generation) }
	{ platform:iOS Simulator, id:BF7AADBE-7D77-43E7-9F65-91EE4F0AE20D, OS:17.0.1, name:iPhone SE (3rd generation) }
	2023-12-11 14:24:51.387 xcodebuild[76667:623924]  IDELaunchReport: 4b09cc2c7898b8c0:4b09cc2c7898b8c0: Finished with error: Could not launch “RunnerUITests”
	Domain: IDELaunchErrorDomain
	Code: 20
	Recovery Suggestion: LaunchServices has returned error -10661. Please check the system logs for the underlying cause of the error.
	User Info: {
	    DVTRadarComponentKey = 113722;
	    IDERunOperationFailingWorker = IDELaunchServicesLauncher;
	}
	--
	The operation couldn’t be completed. (OSStatus error -10661.)
	Domain: NSOSStatusErrorDomain
	Code: -10661
	User Info: {
	    "_LSFunction" = "_LSOpenStuffCallLocal";
	    "_LSLine" = 4141;
	}
	--
	2023-12-11 14:24:51.387 xcodebuild[76667:623924]  IDELaunchReport: 4b09cc2c7898b8c0:4b09cc2c7898b8c0: com.apple.dt.IDERunOperationWorkerFinished {
	    "device_model" = "MacBookAir10,1";
	    "device_osBuild" = "14.1.2 (23B92)";
	    "device_platform" = "com.apple.platform.macosx";
	    "dvt_coredevice_version" = "348.1";
	    "dvt_mobiledevice_version" = "1643.40.14";
	    "launchSession_schemeCommand" = Test;
	    "launchSession_state" = 1;
	    "launchSession_targetArch" = arm64e;
	    "operation_duration_ms" = 29;
	    "operation_errorCode" = 20;
	    "operation_errorDomain" = IDELaunchErrorDomain;
	    "operation_errorWorker" = IDELaunchServicesLauncher;
	    "operation_name" = IDERunOperationWorkerGroup;
	    "param_debugger_attachToExtensions" = 0;
	    "param_debugger_attachToXPC" = 0;
	    "param_debugger_type" = 1;
	    "param_destination_isProxy" = 0;
	    "param_destination_platform" = "com.apple.platform.macosx";
	    "param_diag_MainThreadChecker_stopOnIssue" = 0;
	    "param_diag_MallocStackLogging_enableDuringAttach" = 0;
	    "param_diag_MallocStackLogging_enableForXPC" = 0;
	    "param_diag_allowLocationSimulation" = 1;
	    "param_diag_checker_tpc_enable" = 0;
	    "param_diag_gpu_frameCapture_enable" = 3;
	    "param_diag_gpu_shaderValidation_enable" = 0;
	    "param_diag_gpu_validation_enable" = 1;
	    "param_diag_memoryGraphOnResourceException" = 0;
	    "param_diag_queueDebugging_enable" = 1;
	    "param_diag_runtimeProfile_generate" = 0;
	    "param_diag_sanitizer_asan_enable" = 0;
	    "param_diag_sanitizer_tsan_enable" = 0;
	    "param_diag_sanitizer_tsan_stopOnIssue" = 0;
	    "param_diag_sanitizer_ubsan_stopOnIssue" = 0;
	    "param_diag_showNonLocalizedStrings" = 0;
	    "param_diag_viewDebugging_enabled" = 0;
	    "param_diag_viewDebugging_insertDylibOnLaunch" = 0;
	    "param_install_style" = 2;
	    "param_launcher_UID" = 2;
	    "param_launcher_allowDeviceSensorReplayData" = 0;
	    "param_launcher_kind" = 0;
	    "param_launcher_style" = 0;
	    "param_launcher_substyle" = 8192;
	    "param_runnable_appExtensionHostRunMode" = 0;
	    "param_runnable_productType" = "com.apple.product-type.application";
	    "param_structuredConsoleMode" = 0;
	    "param_testing_launchedForTesting" = 1;
	    "param_testing_suppressSimulatorApp" = 1;
	    "param_testing_usingCLI" = 0;
	    "sdk_canonicalName" = "macosx14.0";
	    "sdk_osVersion" = "14.0";
	    "sdk_variant" = macos;
	}


	*** If you believe this error represents a bug, please attach the result bundle at /Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult

	2023-12-11 14:24:55.784 xcodebuild[76667:623907] [MT] IDETestOperationsObserverDebug: 5.522 elapsed -- Testing started completed.
	2023-12-11 14:24:55.784 xcodebuild[76667:623907] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
	2023-12-11 14:24:55.784 xcodebuild[76667:623907] [MT] IDETestOperationsObserverDebug: 5.522 sec, +5.522 sec -- end

	Test session results, code coverage, and logs:
		/Users/bartek/dev/leancode/patrol/packages/patrol/example/build/ios_results_1702301088962.xcresult

	Testing failed:
		Could not launch “RunnerUITests”
		RunnerUITests-Runner encountered an error (Failed to install or launch the test runner. (Underlying Error: Could not launch “RunnerUITests”. LaunchServices has returned error -10661. Please check the system logs for the underlying cause of the error. (Underlying Error: The operation couldn’t be completed. (OSStatus error -10661.))))

	** TEST EXECUTE FAILED **

	Testing started
✗ Failed to execute tests of app with entrypoint test_bundle.dart for iOS simulator on simulator iPhone 15 (xcodebuild exited with code 65) (10.0s)
Error: xcodebuild exited with code 65
#0      throwToolExit (package:patrol_cli/src/base/exceptions.dart:7:3)
#1      IOSTestBackend.execute.<anonymous closure> (package:patrol_cli/src/ios/ios_test_backend.dart:188:9)
<asynchronous suspension>
#2      DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#3      IOSTestBackend.execute (package:patrol_cli/src/ios/ios_test_backend.dart:148:5)
<asynchronous suspension>
#4      TestCommand._execute (package:patrol_cli/src/commands/test.dart:272:7)
<asynchronous suspension>
#5      TestCommand.run (package:patrol_cli/src/commands/test.dart:169:23)
<asynchronous suspension>
#6      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#7      PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:318:18)
<asynchronous suspension>
#8      PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:262:18)
<asynchronous suspension>
#9      patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:68:20)
<asynchronous suspension>
#10     main (file:///Users/bartek/.pub-cache/hosted/pub.dev/patrol_cli-2.3.1+1/bin/main.dart:6:20)
<asynchronous suspension>

See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it.
$ xcrun simctl uninstall 14F71B6C-42E4-4312-9230-2CB2828CCBFE pl.leancode.patrol.Example
$ xcrun simctl uninstall 14F71B6C-42E4-4312-9230-2CB2828CCBFE pl.leancode.patrol.Example.RunnerUITests.xctrunner
patrol doctor
$ patrol doctor
Patrol CLI version: 2.3.1+1
Program adb found in /Users/bartek/androidsdk/platform-tools/adb
Env var $ANDROID_HOME set to /Users/bartek/androidsdk
Program xcodebuild found in /usr/bin/xcodebuild
Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
flutter doctor
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.2 23B92 darwin-arm64, locale en-PL)
    • Flutter version 3.16.0 on channel stable at /Users/bartek/fvm/versions/3.16.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (4 weeks ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/bartek/androidsdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/bartek/androidsdk
    • Java binary at: /Users/bartek/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/bartek/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3)
    • IntelliJ at /Users/bartek/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 77.0.1
    • Dart plugin version 233.11799.172

[✓] VS Code (version 1.85.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Connected device (3 available)
    • iPhone 15 (mobile) • 14F71B6C-42E4-4312-9230-2CB2828CCBFE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 14.1.2 23B92 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 119.0.6045.199

[✓] Network resources
    • All expected network resources are available.

• No issues found!
Xcode
$ xcodebuild -version
Xcode 15.0.1
Build version 15A507
@bartekpacia bartekpacia added bug Something isn't working package: patrol Related to the patrol package (native automation, test bundling) package: patrol_cli Related to the patrol_cli package labels Dec 11, 2023
@bartekpacia
Copy link
Contributor Author

It seems as if it tries running my tests not on the iOS Simulator, but on my MacBook.

@piotruela piotruela self-assigned this Dec 12, 2023
@bartekpacia
Copy link
Contributor Author

bartekpacia commented Dec 12, 2023

I tried running it today and magically, it (patrol test in both apps) started working. More precisely, it seems that the -destination flag started working:

-- xcodebuild: WARNING: Using the first of multiple matching destinations:
	{ platform:iOS Simulator, id:42D0DABF-5641-42E8-9184-B51281116BA5, OS:17.0.1, name:iPhone 15 }
	{ platform:iOS Simulator, id:42D0DABF-5641-42E8-9184-B51281116BA5, OS:17.0.1, name:iPhone 15 }

It no longer finds "all the devices" and starts running on macOS beacuse it's "the first of multiple matching destinations".

The questions remains why it duplicates these iPhone 15 simulator lines in output, but at least it works.

@piotruela
Copy link
Collaborator

I was not able to reproduce this issue. I found a discussion about this. Seems like some random issue with XCode 15.

@bartekpacia
Copy link
Contributor Author

Good find @piotruela.

I also found a nice post by Bitrise (linked to from the Discussion you found):

I also saw much higher CPU usage when running tests on Xcode 15.

@bartekpacia
Copy link
Contributor Author

bartekpacia commented Dec 13, 2023

Xcode 15.1 got released today

EDIT It doesn't help.

@piotruela piotruela removed their assignment Dec 14, 2023
@jBorkowska jBorkowska added the P1 High-priority issues at the top of the work list label Dec 14, 2023
@MirzaCickusic
Copy link

@bartekpacia were you able to resolve this?

@bartekpacia
Copy link
Contributor Author

Nope.

@Noxiver
Copy link

Noxiver commented Jan 20, 2024

How can i run test with this error?
Any solutions?

@MirzaCickusic
Copy link

I was able to resolve this by updating to the latest code xcode 15.2 and running the tests on 17.2 iOS.
Patrol CLI version: 2.6.2

@jBorkowska
Copy link
Collaborator

jBorkowska commented May 28, 2024

This issue is probably caused by some changes in Xcode 15 - I got the same error and we noticed that patrol chooses wrong version of simulator sdk to build the tests. In my case, it always chooses 17.5, but tries to run on iOS 16.4 (that's the version I wanted to run).

WORKAROUND:

  1. Install Xcode 14.x (or older)
  2. Set it as active eg. using xcodes tool. This way, Patrol can use xcode command-line tools in version shipped with older xcode

Now the build is correct, but you can experience another issue - no matching destinations found. Somehow xcodebuild command assumes, that if we don't specify OS version in -destination argument, it picks latest, which is wrong in this case.
To fix this, you can modify this line, so it looks like this:
'platform=${device.real ? 'iOS' : 'iOS Simulator'},OS=16.4,name=${device.name}',
where 16.4 is OS version on your device or simulator you want to use.
Unfortunately then you have to use local version of patrol_cli, so use dart run /path/to/patrol/packages/patrol_cli/bin/main.dart develop and usual arguments you use

@ivan-horchakov
Copy link

ivan-horchakov commented Jun 5, 2024

@jBorkowska can you share the example of "...local version of patrol_cli, so use dart run /path/to/patrol/packages/patrol_cli/bin/main.dart develop and usual arguments you use" full command?
Originally my issue posted here - I've turned off parallelization for all schemes, this fixed emulator cloning but the "--- xcodebuild: WARNING: Using the first of multiple matching destinations:" with 2 same simulators is still there. So I've installed Xcode 14.3.1 but nothing is changed - after appearing permission dialog nothing happens (I have code for native permission, but it just freezes) and no error in terminal - it just never ends.
TY in advance!

UPD: Discord

@jBorkowska
Copy link
Collaborator

@ivan-horchakov I used dart run /Users/julia/patrol/packages/patrol_cli/bin/main.dart develop -t integration_test/example_test.dart

@andriiShutov
Copy link

andriiShutov commented Sep 18, 2024

Is it fixed in xcode 16?
I cant use xcodes because I need to login with apple id inside xcode ui, that I can't run because of old version.
Any solutions?

UPD: xcode 16 - still reproducing

@andriiShutov
Copy link

I've managed to fix this.
After update to macos 16:

  1. Delete all ios emulators
  2. rm -rf /Users/user/Library/Developer/Xcode/DerivedData
  3. Mac System Settings -> Storage -> Developer(delete there all data)
  4. Install iPhone 16 pro emulator (iOS 18.0)

@Kendru98
Copy link
Contributor

Kendru98 commented Oct 7, 2024

I have also this problem sometimes, especially after connect external disk to macOS and move repo there (maybe not related). But I deleted all iOS versions from xcode and then install just iOS 17.5 it's working for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 High-priority issues at the top of the work list package: patrol_cli Related to the patrol_cli package package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

No branches or pull requests

8 participants