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

旧街凉风 提交于 2019-11-28 09:35:11
rintaro

Try Editor > Execute Playground from Xcode menu

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

Cem Bego

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 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.

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

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

(Running Xcode 8.3)

Gagandeep Gambhir

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

As in Xcode version 10.2 the "Execute Playground" command in the "Editor" menu has been replaced by "Run Playground" and has a shortcut by default + SHIFT + ENTER

The reason why it doesn't refresh when you enter the same command again, is because Playground is already running. You first need to stop the Playground by either clicking on the stop button or entering your own shortcut as I did.

Screenshot

To do so go in

Xcode > Preferences > Key Binding

and look for "Stop Playground".

Add the shortcut you would like to use clicking in the empty field on the right. I entered:

+SHIFT + >

screenshot

In this way you can use the default shortcut to run the playground and you use the custom shortcut to stop it. Once stopped you can run it again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!