xcode - Swift Playground 没有显示错误

标签 xcode swift-playground

我正在开始 Swift 并在 macOS 的 Swift 游乐场中使用教程。

所以示例代码是

var str = "Hello, playground"
str
str1

我在 str 1 上没有收到任何红色错误信息。只是控制台崩溃了
Playground execution failed: error: MyPlayground.playground:1:1: 
error: use of unresolved identifier 'str1'
str1
^~~~


* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
   * frame #0: 0x0000000102157360 com.apple.dt.Xcode.PlaygroundStub-macosx`executePlayground
     frame #1: 0x000000010215522a com.apple.dt.Xcode.PlaygroundStub-macosx`-[PlaygroundViewBridgeService execute] + 90

如果我更正了代码,那么操场会刷新并显示新数据,它只是不报告错误

如何阻止 Xcode 崩溃并按照文档进行操作?

Xcode 版本 8.3 (8E162) macOS 10.12.4

我已经尝试删除所有 Xcode 文件(包括它在构建过程中创建的文件)并重新安装和使用不同的用户

最佳答案

实际上,游乐场确实显示了 “代码左侧红色标记错误”并且还有一个自动选项来修复错误,就像常规项目一样。

enter image description here

我和你有同样的问题(左边没有出现红色标记)。什么解决了我:

  • 右键单击问题导航器(左上面板)上的错误
  • 在菜单 > 打开方式 > 快速查看
  • 然后再次执行相同的命令并打开为> Playground Page

  • 我在 Xcode 8.3.2

    更新:同样适用于 Xcode 9.0

    关于xcode - Swift Playground 没有显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43241749/

    相关文章:

    iphone - NSDecimal 需要桥接

    ios - 使arkit相机垂直而不是水平

    swift - 在 Swift Playground 中调试断点?

    swift - 如何在 Swift 上为堆栈声明 "if optional"

    swift - swift 中的 Nil 合并运算符返回一个奇怪的结果

    string - Swift 初始化(计数 :, 重复值 :) work?

    json - 从 GoogleApiBooks 解析 JSON

    ios - 向现有本地化应用程序添加新语言

    ios - 如何添加 iPhoneX 启动图像

    swift - 将图像添加到 swift playgrounds [iPad]