Simulator freezes – Xcode 8.3.3 - ios

Recently I started to experience problems with iOS Simulator. It's strange but it never happened before.
When I run project it works fine for 10 minutes or so. But then it writes this messages to console:
Exiting because our workspace host has disconnected.
and
XPC connection interrupted
and simulator freezes (doesn't respond to touches).
Restarting of simulator doesn't help, I get alert in Xcode:
Error returned in reply: Connection invalid
Software caused connection abort
If I restart Xcode it works fine again... for next few minutes.
How to fix that?

I fixed this issue. I had Xcode 9 beta installed alongside Xcode 8.3.3 and called xcode-select to switch to Xcode 9. Looks like this was root of an issue.
When I switch back via xcode-select -s <path/to/Xcode.app> this issue disappeared.

Related

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.

Waiting for {simulator/device} to start

With Xcode 9.3 (beta), I'm facing an issue with Xcode tool, while I try to build/run the application (project) for the first time, after Xcode launch/start.
Several times, it prevents project build with the message on status bar:
Waiting for iPhone-X to start
While my simulator is already started and working (There is no any activity, going on, in the simulator).
Here is reference snapshot:
As a temporary solution, I force close Xcode (9.3) and start again.
Is there anyone facing the same issue with Xcode 9.3 beta?
Update: Same issue in Xcode 9.3-Beta 2 also.
Here is How I fixed:
Due to quirks (most likely Simulator bugs) in the Simulator launching on both Xcode 8 and 9, there is no common code to have it launch successfully on both Xcodes. Through experimenting, I have found these to be most reliable:
Xcode 9:
killall Simulator
xcrun simctl boot <device_id>
open `xcode-select -p`/Applications/Simulator.app
Xcode 8:
killall Simulator
xcrun simctl shutdown booted
xcrun instruments -w <device_id>
refer: [iOS 11][Xcode 9] launch, install, start hangs Simulator #209
What (most of the time) works for me, is first launch it on a device. Kill it and then run it on a simulator.
Make sure you don't have the previous Xcode's version of Simulator running when you attempt to run Simulator from the new Xcode, because Xcode will attempt to use that one. (each Xcode bundles it's own Simulator)
Shut down the old Simulator, and try again.
Also, make sure in Xcode > Preferences > Locations > Command Line Tools is pointing to the current Xcode build.
What worked for me : open the simulator device manually (File -> Open Device -> pick the one). Then restart it by going to Device -> restart.
Then try rerunning on xcode.
I've experienced this lots of times especially in beta releases, until I discovered a 'hack' or perhaps a nice way to prevent such issue. But before that, I might add as well this SO link that has a compilation of .dmg Xcode download links. How to download Xcode DMG or XIP file?
TL;DR In order to prevent this kind of issue, just stop debugging or click on STOP button before building/running your application.

Xcode 9.2 Simulator Debugging Broken; Could not attach to process id

Xcode 9.2 debugging on an iOS Simulator has completely broken for me.
I worked on this for hours and tried a ton of suggestions short of completely wiping my hard drive and starting out with a fresh operating system install. I ended up filing a bug with Apple. Posting here in case anyone has encountered this problem and has any suggestions.
Summary:
When try to build and run in debug mode with a debug executable. The simulator only opens the application to a white screen and then Xcode pops up an error:
Could not attach to pid: "<a process id>"
Ensure "<app>" is not already running, and "<user>" has permission to debug it.
Steps to Reproduce:
Make any project and try to run on any simulator.
Expected Results:
Debugger successfully attaches to debugger.
Actual Results:
Debugger is never able to attach to the iOS simulator process/app for debugging.
Debugger CAN attach and build and run successfully on a physical device.
Version/Build:
- Xcode Version 9.2 (9C40b)
- macOS Sierra 10.12.6
- Any iOS project
- Any iOS simulator
Other notes:
- Xcode 9.2 was working fine until this problem randomly started. The error initially said:
Failed to initiate service connection to simulator
DTServiceHubClient failed to bless service hub for
simulator iPhone 8 Plus <simulator identifier>
- After rebooting computer, the error shifted to "Could not attached to pid..."
I tried dozens of suggested solutions short of completely wiping my computer including:
Resetting device contents and settings on simulators
Create a new device (even different device and OS combinations)
Try different Xcode projects, even simple one-off single view applications
Looking at the etc/hosts file and verifying localhost can be pinged
Restarting computer multiple times
Deleting out derived data (multiple times)
Let it build and run without attaching debugger, then try to attach debugger by "attach to process id"
Completely uninstalling Xcode and all simulators, and reinstalling.
Removing any invalid certificates in keychain
It turns out our security software was blocking the debugger. Running sudo sysdiagnose helped me find a log entry showing that it was being blocked. The software is Cb Defense (Carbon Black Defense). Apparently the only workaround is for your security team to whitelist by a hash, and that hash could change in the future.
There is a bug in Xcode 9.0-9.2 that causes this issue to appear after running for a while. If you log out and back in it should resolve it for you.

The iOS 8.1 simulator runtime is not available error in Xcode 6.1

I was using Xcode 6.0.1 till now and things were fine. Then I upgraded to Xcode 6.1 and tried running my application(which has a deployment target of 7.0) in iPhone 6 simulator. But it shows an error message :
The iOS 8.1 simulator runtime is not available. Download the iOS 8.1 simulator runtime from the Downloads section in Xcode's Preferences
I manually deleted the earlier Xcode (6.0.1) and installed 6.1 from a dmg.
I tried searching across but couldn't find related stuff. Any help would be appreciated.
It is a Mac problem, not an Xcode problem.
Logout the user, shutdown, restart or just reboot Mac. Your Xcode simulator will go back to normal.
For anyone still facing this issue, this command worked for me:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
Rebooting did not help me.
Installing/Reinstalling Simulators worked!!
Look under (XCode Preferences-> Downloads -> Components)
Maintain an accurate list of iOS simulators
When upgrading, you may drag around old simulators no longer available with your current version of Xcode. You can clean these by running this command in Terminal:
xcrun simctl delete unavailable
Quit Xcode first just for good measures. From the documentation:
Delete a device or all unavailable devices.
Rebooting my computer fixed this exact issue for me. Same error was thrown for both iOS7 and iOS8 simulators. I'm on OS X 10.10 and Xcode 6.1.
Just had this problem with Xcode 8 beta 5. I downloaded ios8 and 9 simulators, but was not able to run my app. I simply deleted derived data and rebooted my computer. It worked for me.

App is giving SIGABRT when running on already running simulator

When I am running the application from XCode through the simulator for the first time its running fine. But when the application is running in the simulator and if I run again from the XCode the app is stuck at splash screen, and the app is giving SIGABRT crash. When I stop the build from XCode the app continues to run from the splash screen. What might be the issue?
If you are running Xcode 4.6.2 on OSX 10.8.4, try upgrading to Xcode 4.6.3 which was just released a few days ago. The 4.6.3 version has fixes for the random crashes and hangs that sometimes happens when debugging on the ios simulator.
This is XCode issue. Sometimes the bootstrap fails to register the application. Usually giving an error on console as
Couldn't register com.compname.yourapp with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Program received signal: “SIGABRT”.
Solution
If running on device, switch off and restart device.
If running on simulator, restart your Mac.

Resources