如何防止 Xcode 7 Playgrounds 自动运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34269297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:19:02  来源:igfitidea点击:

How do you prevent Xcode 7 Playgrounds from automatically running?

iosxcodeswiftrefreshswift-playground

提问by BK15

I'm working on an Xcode 7 Playground that has many things running at once. Whenever I make an edit, it refreshes, restarts what was running and runs through the entire code again. That crashes my playground around every 15 minutes. Is there a way to prevent playgrounds from automatically running whenever I make an edit?

我正在开发一个同时运行很多东西的 Xcode 7 Playground。每当我进行编辑时,它都会刷新、重新启动正在运行的内容并再次运行整个代码。每 15 分钟就会让我的操场崩溃一次。有没有办法在我进行编辑时防止 Playgrounds 自动运行?

回答by Eric Aya

In the lower-left part of the Playground there's a right-facing blue arrow, looking like a "play" button.

在 Playground 的左下方有一个向右的蓝色箭头,看起来像一个“播放”按钮。

Do a long click on this button and you will get two options: "Automatically Run" and "Manually Run".

长按此按钮,您将获得两个选项:“自动运行”和“手动运行”。

Choose the latter to put the Playground is manual mode and start/stop its execution yourself by clicking on this button.

选择后者将 Playground 置于手动模式并通过单击此按钮自行启动/停止其执行。

enter image description here

在此处输入图片说明



You can also trigger the code execution by making a custom shortcut to the "Execute Playground" Editor menu command.

您还可以通过创建“执行操场”编辑器菜单命令的自定义快捷方式来触发代码执行。

Go to Xcode > Preferences...then go to Key Bindings, scroll down to Editor Menu for Playgroundand add a new shortcut of your choice by double-clicking in the right column in front of the Execute Playgroundcommand.

转到Xcode > Preferences...然后转到Key Bindings,向下滚动到Editor Menu for Playground并通过双击Execute Playground命令前面的右列添加您选择的新快捷方式。

enter image description here

在此处输入图片说明

回答by Frédéric Adda

Actually, you CAN map a shortcut for "Execute Playground" to Cmd+R.

实际上,您可以将“执行操场”的快捷方式映射到Cmd+ R

Use macOS keyboard shortcuts, instead of Xcode's keybindings.

使用 macOS 键盘快捷键,而不是 Xcode 的键绑定。

Go to System Preferences> Keyboard> Shortcuts,

转到System Preferences> Keyboard> Shortcuts,

and in App shortcuts, click on +.

并在 中App shortcuts,单击+

Choose Xcode.app, and add a new shortcut for "Execute Playground" (you have to type precisely this!). Shortcuts 1

选择Xcode.app,并为“执行操场”添加一个新的快捷方式(您必须准确地输入这个!)。 快捷键 1

Then click on Add. Shortcuts 2

然后点击Add快捷方式 2

Now you can use this shortcut in Xcode. Xcode menu shortcut

现在您可以在 Xcode 中使用此快捷方式。 Xcode 菜单快捷键

And don't worry for conflicts (at least up to Xcode 9): Execute Playgroundis not available for standard Xcode projects, and Runis not active for Playgrounds.

并且不要担心冲突(至少到 Xcode 9):Execute Playground不适用于标准 Xcode 项目,并且Run不适用于 Playgrounds。