skip to Main Content

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:

  1. Restarting Xcode and rebooting my macbook
  2. Stopping the simulator via the Activity monitor and restarting it
  3. Opening up new tabs in an attempt to refresh
  4. Uninstalling and reinstalling Xcode via the app store
  5. 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


  1. Chosen as BEST ANSWER

    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


  2. Swift Playgounds don’t work for me if Xcode 12 was launched in the "Open using Rosetta" mode.

    Solution:

    1. Go to "Applications" folder -> Right click on the Xcode -> "Get Info" menu item

    Get Info menu

    1. Unselect "Open using Rosetta" checkbox.

    enter image description here

    Close (Cmd+Q) Xcode and open it again. Next time it will be opened without Rosseta and playgrounds should work fine.

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. Two causes to this that I have seen.

    1. Xcode is opened with Rosetta checked.
    2. The build tools are not selected in Preferences > Locations > Command Line Tools:.

    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.

    Login or Signup to reply.
  5. Running Xcode 14.1 and macOS Ventura 13.0.1

    Was struggling with this as well, fixed it:

    1. Go to playground settings on the right side
    2. Select macOS under platform

    It’s not perfect solution, but it works for now.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search