Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: Any way to refresh/re-run the playground?

People also ask

How do I restart playground?

In the Swift Playgrounds app on your Mac, go to the page you want to reset, then choose File > Start Page Over.

Why is my Xcode playground not running?

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.

How do I run a playground in Xcode?

Simply click the Run button at the bottom-right of the playground, and wait for execution to complete. Xcode now compiles your code, and shows you its result. The default code doesn't output anything to the Console, but you should be able to see the value of the variable str in the sidebar on the right of Xcode.

What is the difference between playground and Xcode?

An Xcode project allows you to create real apps that you could eventually upload to the App Store (providing you became an Apple Developer). An Xcode Playground allows you to play with code and test it out. It isn't for mainstream developing.


Try Editor > Execute Playground from Xcode menu

enter image description here

I don't know what Reset Playground is, by the way.


In addition to the other responses, playground execution can also be controlled with the button on the bottom bar above the debugger console. There are two buttons on the left side of the console; the one on the left opens/closes the console and the one on the right controls the execution of the playground and changes depending on whether the playground is currently running.

If you hover over the button a small black triangle will appear in the bottom corner of the button. If you long press on the button the menu in the screenshot below will appear, where you can change the execution mode of the playground between automatically or manually running. If it's automatic, then it should run once every time you make a change (unless you make a change while it's running, then it will interrupt itself and run again). If it's manual then you have to press the button to run the playground.

playground menu

While running the button is a hollow square, like a stop button on a VCR. Pressing it will stop the execution.

stop

When it's not running it is a blue triangle, like a play button on a VCR. Pressing it will run the playground.

play

(Running Xcode 8.3)


Also, you can create your shortcuts.

Xcode > Preferences > Key Binding > (Search Execute Playground)

It is empty as a default, but you can assign anything.

Xcode 11 > Preferences > Key Binding > (Run Playground)


In Xcode 10.1 there is a "Run Playground" command in the "Editor" menu which can be accessed via the following keyboard shortcut:

Command + Shift + Enter

screenshot of menu showing Run Playground