Playgrounds get stuck "Running..."

This is annoying to a point where Playgrounds are basically useless. Happens to me all the time. Best MBP and all the latest versions.

Defeats the whole purpose of Playgrounds if it takes minutes to get them running. Have to quit Xcode all the time.

I've had luck when I stopped my multipass VMs (A Ubuntu VM orcchestrator which has been adapted for the new virtualisation API). I would assume something like Docker or some other VM software could be interfering with this.
An iOS playground appears to perform better than a MacOS one. It still takes too long to run in my opinion but at least iOS seems to work.

Edit: I'm on Xcode 12.2

Same problem on Xcode 12.2,

it was working fine for a few minutes, and then it just stops. It won't print anything on the console, but it does still tell me where I make mistakes.

I left it running for like an hour now and still nothing. I restarted Xcode multiple times and it doesn't fix anything for me!

Apple if you are reading this, this is a major problem that you have to fix as soon as possible! I use playgrounds all the time to test my codes and ever sense I got Xcode 12 it just won't work properly.

im on a MacBook Air (Retina, 13-inch, 2019) with Big Sur version 11.0.1
I got a work around with live view. If you press
opt + command + Enter, you should see the real time result.

Not really the solution but at least a bandaid one.

Having the same issue December 2020. Really simple codes not running after 5+ minutes of spinning wheel.

Xcode 12.2
macOS Big Sur 11.0.1

Macbook Pro, Retina, early 2015,3.1 GHz Dual-core Intel Core i7, 16 GB Memory
This is my playground:

Code Block Swift
import Foundation
let uuid = UUID().uuidString


I've been waiting minutes for output. I even set it to be a macOS platform as I'm told this speeds up compile and execution times.

My issue was going back to the playground file after a while the playground was running for ever. I just clicked stop playground in the editor menu and then clicked run... it solved my issue for me.
Just had the same issue on Big Sur. 27" iMac 2017 3.4 Ghz i5, 8GB model. Xcode 12.4

Fixed it by creating a new playground > Selecting macOS instead of iOS. > Save File Name (example1.playground)

I can confirm that choosing iOS instead of macOS is the issue, as I created another iOS playground and it doesn't run.

Hope this helps!

I'm using Xcode 13 Beta 4 and still running into this. I found another workaround (I'll use MacOs playground when possible).

Whenever I accidentally hit an infinite loop (happens a lot doing DP problems :) ) and hit the Square in the lower left to Stop I'm doomed.

Once stuck in this state, even if you kill Xcode when you open it, it immediately starts running again (with the bad code). Even if I fix the code, it just starts up and gets stuck.

My project is in GIT and noticed this difference in the project (contents.xcplayground)

It adds and sets a flag executeOnSourceChanges='true', I just revert that change and I'm good to go. Also if I do run into an infinite loop and just kill Xcode rather than try to stop it, that also avoids the problem.

This is the Diff of contents.xcplayground (this file is inside your playground project "content folder")

I might try adding that attribute and set it false and see if that prevents it from getting set true. Rather than absent.

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
+<playground version='5.0' target-platform='ios' buildActiveScheme='true' executeOnSourceChanges='true' importAppTypes='true'>
     <timeline fileName='timeline.xctimeline'/>
 </playground>

11-04-2021, Xcode 13.1 (13A1030d), MBP M1/16/512 I have to admit: the bug is still there...

12-17-2021 Xcode Version 13.2 (13C90) MBP 13-inch,i7, 2017, macOS 11.6.1 I honestly can't believe how after all this years the bug is still there. It is extremely anoying to have to restart Xcode everytime I want to test something in playgrounds

MacOS Monterey 12.2.1, Xcode Version 13.2.1 (13C100). Still, playground running forever. Have to restart Xcode...

Playgrounds are supremely unreliable and honestly Apple should just shut them down if they're not going to invest in making them more reliable and usable.

Playgrounds get stuck "Running..."
 
 
Q