Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 12.5 Playgrounds not displaying any outputs or running code

Tags:

xcode

ios

swift

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.

like image 768
Jake Avatar asked Dec 31 '22 14:12

Jake


2 Answers

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.

like image 178
Petr Lazarev Avatar answered Jan 02 '23 04:01

Petr Lazarev


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

like image 21
Leandro Avatar answered Jan 02 '23 04:01

Leandro