Xcode 12.5 playgrounds don’t seem to run any code at all, or display line by line outputs when ran. When I make a new playground, and click on any line of code to run, or try to run all the lines of code with the button at the bottom of the screen, I am shown in the top bar: "Build test (Playground): Succeeded" but there is no output in the command prompt, even when print statements are added, and there is no information in the side bar.
I’ve tried:
- Restarting Xcode and rebooting my macbook
- Stopping the simulator via the Activity monitor and restarting it
- Opening up new tabs in an attempt to refresh
- Uninstalling and reinstalling Xcode via the app store
- Switching the playground settings for Platform from iOS to macOS
All to no avail.
I’ve tried opening other playgrounds from downloaded files (e.g. the swift tutorial from apple’s website) and they all give me the same results, which is opening the code but not displaying any results in the side bar or running the code.
I’m currently on an M1 Macbook Pro 2020, with 8gb of RAM, as well as MacOS version 11.4
Here is a picture of what I see
Edit:
Changing whether the playground runs automatically does not affect the output of Xcode. Both automatic and manual result in not running any portion of the playground.
5
Answers
It seems like Xcode playgrounds seem to be completely broken (at least for my setup). For anyone else trying to learn swift that's experiencing this problem, instead of using playgrounds I created a new command line project in Xcode in order to run the Swift files. How to do this is outlined here: https://www.aidanf.net/learn-swift/running_code
Swift Playgounds don’t work for me if Xcode 12 was launched in the "Open using Rosetta" mode.
Solution:
Close (Cmd+Q) Xcode and open it again. Next time it will be opened without Rosseta and playgrounds should work fine.
I was having this issue, changing in the Playground Setting in File inspector from iOS to macOS and you will have to use Foundation module instead of UIKit. I am using Xcode 12.5.1
Two causes to this that I have seen.
I’ve had the build tools magically deselect themselves for some reason. Rosetta was selected to allow certain pod files to build when the Simulator is targeted on an M1 Mac.
Xcode should fire off an error if there are no dev tools selected, but for some reason it doesn’t do that and just displays nothing in the console and no error message at the top of the screen as it does for other errors.
Running
Xcode 14.1
andmacOS Ventura 13.0.1
Was struggling with this as well, fixed it:
playground settings
on the right sidemacOS
underplatform
It’s not perfect solution, but it works for now.