Quit Xcode and Open All Up Again
Bound to the solution if TL;DR
Ever stuck in 'Launching Simulator' or 'Running Playground' when y'all fire up Playground to write some lawmaking? Despite restarting Xcode or fifty-fifty Mac multiple times, the trouble still persists? I accept seen many beginners give upwardly on learning Swift because of this issue and this really sadden me, Apple should do meliorate on this. Apple recommends beginner to utilise Playground and nonetheless Playground is full of problems like this 🤦♂️.
I ran into this consequence last week while trying out NSPredicate examples in Playground, it happened after an error during execution of code.
After the error appeared, no large deal, I changed the code and run it again, and then the Playground got stuck in Running... 😱. Then I quit Xcode and open the Playground again, and the aforementioned issue persist 😭.
I tried restarting Xcode, Mac to no avail and about attempt to reinstall Xcode. Then I noticed it stuck on "Launching Simulator" and idea it might take something to do with the iOS Simulator since restarting Xcode doesn't help 🤔.
When y'all create a Playground in Xcode, it volition use iOS platform to run the code by default. To run it on iOS platform, the Playground volition spin up an iOS Simulator in the groundwork.
And it is this iOS Simulator thing that causes the stuck problems! Restarting Xcode doesn't work because the simulator procedure doesn't get restarted when you restart Xcode equally it is a split up process.
Somehow the CoreSimulator process become unstable after an error got raised in the Playground. It will become stuck after the fault and remain stuck until yous kill this process. That'due south the reason why you keep stuck on "Launching Simulator" or "Running.." even after restarting Xcode.
Workaround Solution
The solution for this is to switch to macOS platform in the Playground, let the playground code run in your macOS environment directly instead of spinning up an iOS simulator process to run information technology.
First, ensure your Playground doesn't utilize any UIKit function (eg: UIView etc), and remove the top import UIKit line if information technology is there.
So in the correct pane of the Playground window, select 'macOS' in Playground Settings -> Platform .
I too suggest switching to manually run instead of automatic run in the playground to reduce the CPU usage.
Now yous should exist able to run the Playground successfully, cheers! 🍻
The caveat of this solution is that yous have to remove import UIKit and all UIKit related functions as macOS doesn't support UIKit.
Workaround Solution if you lot need to use UIKit
If you are using UIKit functions in Playground, you have to utilise iOS Platform every bit UIKit is iOS-exclusive.
The solution for solving the stuck issue then volition be to quit Xcode, open 'Activity Monitor' (In Spotlight, type 'Activity Monitor'), search for 'simulator' ,highlight com.apple tree.CoreSimulator , and forcefulness quit it.
And so open Xcode again , information technology should work fine now. If you got whatever error during code execution in Playground, you will need to echo these steps. I recommend switching to manually run in Playground so that the Playground won't motorcar run the incomplete code while you are typing to foreclose occurrence of error.
Tired of fighting with Auto Layout constraints? Why is it then hard to make a layout to work?! Would using code for UI and constraints brand it easier? (No, not actually) If you desire to understand Auto Layout fundamentally (instead of just post-obit youtube tutorials implementing a very specific layout which might not apply to your app), cheque out my volume Making Sense of Motorcar Layout, with practical case study!
"It helped me empathize how Auto Layout works fundamentally - something that I couldn't find in any tutorial. I realized what Car Layout needs for each view to render it correctly" – Ostik Lebyak
Source: https://fluffy.es/fix-playground-stuck/
0 Response to "Quit Xcode and Open All Up Again"
Post a Comment