如何在Swift Playground书中展示游戏机?

发布于 2025-02-05 14:19:32 字数 760 浏览 3 评论 0 原文

我正在用Xcode创建一本Swift游乐场书籍,使用

现在,我希望我的学生可以使用这本操场书的书有一个控制台,以便他们可以使用 print 语句进行调试。

在Apple提供的游乐场书籍中,通常有一个按钮可以在右角处打开控制台:

<< img src =“ https://i.sstatic.net/oxhfm.jpg” alt =“ Apple Playground屏幕截图”>

但是,当我使用Swift Playgrounds打开自己的游乐场书籍时,没有控制台按钮:

< a href =“ https://i.sstatic.net/eufgi.png” rel =“ nofollow noreferrer”>

我如何在操场书中获得游戏机?

I'm creating a Swift Playground Book with Xcode, using Apple's Swift Playgrounds Author Template.

Now I want my students who will work with this playground book to have a console, so they can use print statements for debugging.

In playground books provided by Apple, there is usually a button to open the console in the lower-right corner:

Apple Playground Screenshot

However, when I open my own Playground Book with Swift Playgrounds, there is no console button:

Screenshot of my own Playground Book

How can I get a console in my Playground Book?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2025-02-12 14:19:33

终于找到了解决方案。

您必须在操场书的 subtest.plist.plist 文件中设置版本键为版本 8.0 (我猜)。

或直接编辑文件的源代码:

<key>Version</key>
<string>8.0</string>

没有明显原因,Apple此时不提供最新稳定Xcode版本(13.4)的Swift Playgrounds作者模板(这在当您必须下载匹配的Swift工具链以构建该模板时本身,因此我使用的是最新的模板,而是用于Xcode 13.2的最新模板。该模板的版本将设置为 7.0 ,似乎此游乐场版本尚不支持控制台。

Finally found the solution.

You have to set the Version key in the Playground Book's Manifest.plist file to version 8.0 (or above I guess).

Property List Editor in Xcode

or when editing the file's source code directly:

<key>Version</key>
<string>8.0</string>

For no apparent reason, Apple doesn't provide a Swift Playgrounds Author Template for the latest stable Xcode version (13.4) at this time (which is trouble in itself as you have to download the matching Swift toolchain to even build that template), so I used the newest template available instead which is for Xcode 13.2. This template has the Version set to 7.0 and it seems like this Playground version does not support the console yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文