Error running playground. Unable to find suitable target device. (iOS Swift) - xcode

I created a new project in XCode.
File > New > Playground (option+shift+cmd+N)
I restarted my XCode and also rebooted my system, but still same error.

From the developer forums, this worked for me:
Quit Xcode
Delete the folder /Users/<username>/Library/Developer/CoreSimulator/Devices. For example, in Terminal: rm -rf ~/Library/Developer/CoreSimulator/Devices
In Terminal: killall -9 com.apple.CoreSimulator.CoreSimulatorService (or just reboot).

Fox Xcode 7, I had to install iPad Air or iPad Air 2 for the playground to work.

Another possible way to encounter that issue is to get Xcode being auto-updated, while the simulator was launched.
The solution is like mentioned above but more polite:
Quit Xcode and Simulator app
Run in Terminal: killall -9 com.apple.CoreSimulator.CoreSimulatorService
Launch Xcode and find that all fixed now.
Sure, you can just reboot instead.

Try navigating to the Xcode Menu
Window >> devices (shift+cmd+2) a new window will pop up.
On the bottom left, add a new simulator, specifically one running on iOS 8.0 to the existing list.
Restart Xcode.

As referred by #Mayank Gupta , It worked on adding new simulator and restarting the XCode.

Related

React Native `RuntimeError: abort(Error: xcrun exited with non-zero code: 2` on iOS simulator

I was working on a React Native project with a group and was asked to use the iPhone 13 simulator as a model while working. I only had access to the iPhone 12 simulator, and I saw that my XCode was a version behind, so I updated it. Now with the new XCode, I am getting an error when I start the React Native server and try and open the iOS simulator. the error is shown below:
Running this command with the suggested build with -s Assertions=1 reveals the following:
My package.json is as following:
Any idea what is going on or how to proceed? Expo seems to be able to run, but trying to open the simulator crashes the server. The project I am on is near tight deadlines and I am totally held up by this. Either a way to troubleshoot this error or a way to roll back my XCode install and just live with a dated simulator would be greatly appreciated.
Figured it our thanks to ShepSims from https://github.com/expo/expo-cli/issues/2413 . Before being able to open the iOS simulator from the terminal, I needed to open XCode and open the simulator there. This mounts the simulator bundle, allowing later access by pressing i after running expo start.
I was receiving the same error as above with XCode command line tools installed only, no XCode installed.
I tried re-installing XCode command line tools which didn't do anything.
For me this was solved with advice mentioned at https://github.com/expo/expo-cli/issues/3871:
open Simulator.app, as it automatically sets the default device.
It is not anything. It was solved by opening simulator from XCOde on my mac
The fastest way from my point of view is "spotlight" (Cmd+Space) search for "Simulator", hit enter before running "expo start" in your terminal.
You can solve the problem by using this command
sudo expo start
Or
manually open simulator
start app: react-native run-ios
manually do: Hardware -> Device -> select iOS -> select Device (different than before !)
that will open a second simulator
start the app again: react-native run-ios (expo start then press i)
this opens the app in the selected simulator
Note:- please stay open the silumater then press the i in the expo and same for the react-native run-ios command

When launching an iOS simulator it closes straight away but still runs in the background

When I try to run a project (even a default single view app) in Xcode 10.2 (also occoured on Xcode 10.3 and beta 11 build 3) the simulator launches but then closes but Xcode still thinks it's running (looks like it is running headless). Any ideas on how I can see the simulator?
I have tried the following so far but the only time I can see the Simulator is on its first launch after that it disappears after launching.
Uninstalling and re-installing Xcode (making sure to delete all related directories and doing a system restart)
Adding and removing simulators from window -> Devices and simulators from within Xcode
Tried clearing the simulator cache xcrun simctl erase all
Tried running the following sudo killall -10 com.apple.CoreSimulator.CoreSimulatorService
Clearing Derived data ~/Library/Developer/Xcode/DerivedData/
Another thing I noticed is if I run: /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator I get the following error:
Bus error: 10
But if I run: sudo/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator the Simulator launches fine.
Thanks for any help.

Xcode error connecting to simulator "Software caused connection abort"

When I try to run my project through the Xcode simulator, it keeps giving me the error "Software caused connection abort".
Tried restarting the simulator & Xcode, and I recently deleted the DerivedData folder as suggested in this post about broken playgrounds so that also didn't help.
QUICK FIX
This is happening because you have multiple versions of Xcode installed. MacOS unfortunately only supports running one version of Xcode at a time, and it needs to know the location of the currently running version. To sort things out, choose one of the following:
Quit all instances of Xcode and restart it
Try one of the other options below if that hasn't solved it.
Using the command line:
run sudo xcode-select --switch /Applications/your_custom_folder_if_needed/Xcode.app
Restart your terminal and Xcode and it will work just fine.
No-command line users:
Quit all instances of Xcode
Start the instance of Xcode that you want to use
Go to Xcode -> Preferences -> Locations
Select the correct version in Command Line Tools
Done!
It's due to multiple Xcode installed in your system. This is how you make it work:
Quit all running Xcodes
Re-launch Xcode
Go to Xcode > Preferences > Locations
Change to the correct version in Command Line Tools
Clean project and clear Derived data if necessary, then run!
In my case quitting and re-launching given Xcode was enough. I had two Xcodes, stable and beta.
For me, restarting the Mac OS worked (multiple times).

Weird Strings for iOS version in Xcode simulator list

As you can see in the screenshot, I am getting this weird string for some simulators. How can I fix this?
It happened to me,when there were both Xcode7-beta and Xcode6 in my Mac.
As you see,UDID-like strings are UDIDs (Unique Device IDentification numbers) for the iOS Simulator devices. As they are duplicated devices with unique UDIDs,to there are two ways to solve this problem,:
I suspect the issue will go away if you restart the service:
Quit Xcode, Instruments, and the iOS Simulator and then run this in Terminal.app:
sudo killall -9 Xcode 'iOS Simulator' com.apple.CoreSimulator.CoreSimulatorService
Then
rm -rf ~/Library/Developer/CoreSimulator/Devices
Just change and rename your simulators: In xCode go to Window -> Devices and press the plus in the bottom corner and add the simulators that you wish or minus to remove.
Then it'll be ok:
Thanks to #stevechen for pointing me in the right direction, I finally solved this problem :
Xcode Menu > Open Developer Tools > Open iOS Simulator
iOS Simulator Menu > Hardware > Device > Manage Devices
Delete all the bad entries
Add then back
Enjoy!
I ended up running this:
killall Xcode
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/Developer/CoreSimulator/Devices
open /Applications/Xcode.app
Per this SO answer: https://stackoverflow.com/a/31421158/406
It worked great for me!
Xcode 6.4

Xcode freezes when running app after Yosemite update

After upgrading to Yosemite, Xcode has been unable to run apps on the device. Every time I click on the "Run" button or I do command-R, Xcode freezes. It installs the app on the device, but never launches it. It shows the busy spinning disc and stops responding. Even force quitting Xcode does not help. I have to restart the laptop in order to get Xcode to start again.
I tried it on several apps. These are apps I have been working on for months, it was working fine before Yosemite update.
Things I tried:
I tried installing Xcode 6.2 beta as well. The same happens on both old and new beta Xcode
Restarted the laptop several times.
Deleted and re-installed both versions of Xcode.
Tried running in non-fullscreen mode.
Check to make sure English is the primary language.
Cleared the DerivedData folder completely
Ran the following commands:
rm -rf $HOME/Library/Application Support/Developer/Shared/Xcode
rm -rf $HOME/Library/Preferences/com.apple.dt.Xcode.*
rm -rf $HOME/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
rm -rf $HOME/Library/Developer/Xcode
None of the above seem to work. Why?
Delete the subfolders of Derived Data. Go to ~/Library/Developer/XCode/DerivedData (open the Finder, press cmd+G) and delete all the subfolders. Then restart Xcode. If that doesn't fix the issue, press cmd+shift+K to clean up your project from useless files.
Nothing really helped in the end. It just seemed to be a faulty incremental install on Yosemite, esp. since no one else seemed to face the issue. I couldn't even launch Xcode after sometime.
I just had to back stuff up and make a fresh install after formatting.

Resources