Xcode 14 (on Ventura): "Failed to prevent system sleep during UI testing" when UNIT testing - xcode14

I'm running Xcode 14 beta 5 on macOS Ventura (13.0 Beta (22A5321d)) and when trying to run unit tests, not UI tests, plain old unit tests, I get this super annoying dialog when starting a test.
This is an SPM package, not an .xcodeproj.
If I click details, this is shown:
Details
Failed to prevent system sleep during UI testing. Error code: -536870211
Domain: IDEFoundationErrorDomain
Code: 1
User Info: {
DVTErrorCreationDateKey = "2022-08-17 20:06:42 +0000";
}
--
System Information
macOS Version 13.0 (Build 22A5321d)
Xcode 14.0 (21330) (Build 14A5294e)
Timestamp: 2022-08-17T22:06:42+02:00
Sometimes deleting derived data helps, sometimes not.
Any clues? I did not see this error in Xcode 14 beta 1 I think.

In terminal run: sudo pmset schedule cancelall
This fixed the issue for me on macOS Ventura Beta 5, Xcode 14 beta 6.
The answer came from this comment. It looks like a bug causes process powerd to issue too many assertions to pmset. This causes a problem when another process tries to create a PreventUserIdleSystemSleep assertion.

Related

Getting frequent Kill:9 Error in Xcode and Terminal

I have recently upgraded the Mac OS to Ventura 13.2.1 and Xcode to 14.2, now once I try to compile any application with Xcode, I am getting Kill:9 related issue for random task/framework in the project. I also get Kill:9 issue sometime on terminal as well.
Listing the errors here:
failed to read asset tags: The command `` terminated with uncaught signal 9. The command had no output.
Driver threw jobFailedWithNonzeroExitCode(9, "") without emitting errors.
Unable to execute command: Killed 9 Clang frontend command failed due to signal.
Please help me to resolve this issue/crash.
Open project in Xcode.
Build the app with Simulator (I tried with iPhone 14 Pro)
Error occurs in the build
Ideally project should have compiled without any error.
It sounds to me that the problem is with the installation of Xcode because when an unprivileged task is attempted, the OS will kill it off (with signal 9).
What I recommend is for you to re-install Xcode.
When you first run the new Xcode, it should prompt you for an administrator password in order to install system related components. Make sure you do this step. Hopefully that should then allow you to compile and run your iOS apps.

iOS Observatory not discovered after 30 seconds. Error launching application on iPhone

I'm unable to debug a freshly created app on physical iOS devices when pubspec dependencies reach a certain size, because it causes the "waiting for observatory port" step to timeout after 30 seconds.
Devices tested:
iPhone 12,
iPhone 12 Pro
iOS versions tested:
14.7.1,
14.5
The app runs properly on emulator but not on ios real device.
How do I fix this issue?
This Error message occur when your iPhone is busy processing something. For example as below.
If you run Flutter doctor you will see message as below.
Error: iPhone X is busy: Fetching debug symbols for iPhone X. Xcode will continue when iPhone X is finished. (code -10)
To confirm I opened xCode -> windows -> Devices and Simulator and it was showing the progress. Let the progress complete and then confirm by running Flutter doctor to make sure there is no error message.
Had the same problem after updating Xcode and running for the first time. As mentioned on the this github issue (https://github.com/flutter/flutter/issues/72161#issuecomment-994653225) I simply:
Opened ios/Runner.xcworkspace with the iPhone connected
Waited until "Fetching debug symbols" process finished
Closed Xcode
Run again from IDE and it worked!
I have encountered the same issue and following this process has fixed the problem for me on 14.7.1 and 14.8:
Uninstall the app
Restart the phone
Open the app using Xcode
Run 'flutter clean' for the project
Now it should work if you run it again.
If it still doesn't work you could try increasing the observatory timeout (the default appears to be 30 seconds):
localUri = await observatoryDiscovery.uri.timeout(const Duration(seconds: 30));
I'm not 100% sure why this problem appears inconsistently, but there is a lot of related discussion at the following link:
https://github.com/flutter/flutter/issues/72161
For coders who are as lazy as me, you could take these steps:
Open xcode for the project:
Run the project from xcode:
while(prompt_below_finished == false) wait for some time || make a coffee;
Runs successfully. As for me, next time I ran with android studio , it run smoothly
run your project through Xcode, not from Xcode or Android Studio. it will show different error message.
when I run the Flutter project using Xcode, the error message was
"The sandbox is not in sync with the Podfile.lock..."
to solve this, I run pod install on the ios folder. run these 2 commands below on your terminal
cd ios
pod install
I have tried all the solutions here and for me the simplest works:
move you Android Studio in the trash, download it and reinstall. for me the problem was with Android Studio 2021.1.1 Patch but I got there with several updates. a clean install solved the problem.
In My iPad case, It showed a white screen after compiling in the installing step for 5-10 minutes & it worked at the end without doing anything
Try updating your Xcode and MacOS to the latest versions.

Xcode compilation unexpected results

✅ Xcode 10.2.1
I have a project, on which I worked in Xcode 10.2.1. Suddenly it started to get stuck building one of my many pods (one of 2, inconsistently). Says something like "Building <AppName>: <PodName> | Building 749 of 803 tasks". And while idle, it gets stuck "Indexing Text".
Update: This version is unable to Build or Index ANY project I try. True even for unchanged presets.
SOLVED: Restarting my machine was the solution
✅ Xcode 11.0 Beta 1
Just to test, I've opened this project in Xcode 11 Beta (1) and it worked just fine. I was able to Build and Run, Archive but not Distribute (AppStore Connect says tool is unsupported).
❌ Xcode 11.0 Beta 4
The latest available Beta, however, Builds and Runs this project with no problems, however, fails to Archive it.
Additional information
I tried cleaning, restarting; updating CocoaPods; reinstalling and reinitializing all Pods, nothing helped.
The issue appeared, seemingly, out of nowhere, not in between installing or updating any of the Pods.
It worked perfectly in Xcode 11.0 Beta 1, just as one would expect any version of Xcode to work with an .xcworkspace. No warnings, no errors, nothing.
Solved this whole thing by restarting my machine.

Unable To debug with AppCode after upgrading to Xcode 7.3

After I updated Xcode to 7.3 I am unable to start debugging with AppCode 3.3.2 & 3.3.3 I am just able to Run without debugging each time I start debbuging with appcode this happens in the console:
/Users/labib/Library/Caches/AppCode33/DerivedData/TestApp-e195af2c/Build/Products/Debug-iphonesimulator/TestApp.app
Stopping simulator session...
Simulator session started with process 3047
Process finished with exit code 0
JetBrains is aware of this issue and have a fix as part of the current RC (see their latest AppCode blog post).
Their current advice is essentially to download the RC version from their AppCode EAP page if you've already upgraded to XCode 7.3. NOTE: It does require a license or you can use a 30 day eval period.

UI automation error using iOS 5.1 target

I use Instruments 4.3 with UI automation tool for sometime successfully.
Recently I upgraded my target iPhone4 to iOS 5.1 and UI automation is now giving following error :"An error occurred while trying to run the script" for the moment a script is started, no further info than that.
Even when Instruments is running independently from Xcode the problem is still their, also when "run on record" is ticked but no script is selected.
I even reinstalled Xcode 4.3.1 but without success.
Runs fine on simulator and previous iOS version though.
If anyone encountered this issue and has a solution, please reply.
Thanks,

Resources