'How to fix Xcode Playground Communication Error on Xcode 13.2.1 on IOS Big Sur 11.6, please?

I am trying to test some code on Xcode playground. I am receiving the following error:

'Failed to prepare for communication with playground for an unknown reason.'

When I press the play button nothing happens - I have copied the code exactly from a course I am doing which shows results on the demonstration.

I am using Xcode 13.2.1 and on a MacBook Pro (Late 2013 model) running Big Sur 11.6 - I cannot update any further.

I have not had any trouble using the main part of Xcode for my own and cloned projects with no such similar errors.

I have tried to restart Xcode, I have deleted the playground and created a new one and tried using different code. I have searched on the help section on Xcode and on Apple Development as well as on here with no solutions found.

This is the code which I am testing with, which on the demonstration returns 'hello'.

func greeting () { print ("hello") }

greeting()

Thank you :)



Solution 1:[1]

I have managed to find an answer to my own question so thought I would post it incase others are having the same trouble.

I restarted my whole computer on a whim and it is now working perfectly! It obviously got stuck when the just closed the programme and a full reset has allowed it to work again.

Thank you :)

Solution 2:[2]

I did the following for it to work for me (XCode 13.2.1, Monterey):

  1. Went to Finder location for the playground

  2. Right clicked on the .playground and clicked "Show Package Contents"

  3. Selected the .workspace item in the package

  4. Ran the playground

Worked fine thereafter!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ohSophApps
Solution 2 my3vshenoy