Xcode 6 Beta / Swift - Playground不更新

时间:2023-01-23 19:03:05

I was playing around with the Playground feature of Xcode 6's first beta - and I notice half the time the Playground doesn't update (simply doesn't display the result calculation or how many loop iterations are happening) simple code/loops/functions that are in there. Even the Swift Tour https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html

我正在玩Xcode 6的第一个测试版的Playground功能 - 我注意到Playground没有更新的一半时间(根本不显示结果计算或发生了多少循环迭代)简单的代码/循环/函数在那里。甚至是Swift Tour https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html

has several lines of code that don't show up in Playground. If you mess with the code sometimes it will show up, by moving the code around or placing it elsewhere. Anyone else? Any fixes? Is this just a beta problem?

有几行代码没有出现在Playground中。如果你搞乱代码有时它会出现,通过移动代码或将其放在其他地方。还有谁?任何修复?这只是一个beta问题吗?

4 个解决方案

#1


36  

Make sure you haven't inadvertently added an error to your Playground code. Unfortunately, there is no inline notification of an error, and after an error is created, nothing in the Playground will update.

确保您没有无意中向Playground代码添加了错误。遗憾的是,没有错误的内联通知,并且在创建错误后,Playground中的任何内容都不会更新。

To help with this, open up the Assistant Editor (File > View > Assistant Editor > Show Assistant Editor), which should include a Console Output box. If there are any errors in your Playground, they will show up there. Once corrected, your Playground should hopefully update once more.

要解决此问题,请打开“助理编辑器”(“文件”>“视图”>“助理编辑器”>“显示助理编辑器”),其中应包括“控制台输出”框。如果您的游乐场中有任何错误,它们将显示在那里。一旦纠正,您的游乐场应该有希望再次更新。

That said, it can be a bit slow depending on the complexity of your Playground and its size.

也就是说,根据游乐场的复杂程度及其大小,它可能会有点慢。

#2


3  

This answer (Undeclared Type 'NSView' in Playground) did it for me (restarting Xcode and the machine didn't help):

这个答案(Playground中的Undeclared Type'NSView')为我做了(重启Xcode并且机器没有帮助):

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"

#3


1  

Had the same strange errors after upgrading to xcode 6 beta 6. For me the problem got fixed with a Product -> Clean. And if that does not fix the errors hold down option key and click again on Product in the Menubar then you will see in the dropdown menu Clean Build Folder... click on that. Or you could download Watchdog app from appstore. This little helper automatically cleans your xcode projects.

升级到xcode 6 beta 6之后有同样的奇怪错误。对我来说,问题已通过产品 - >清理修复。如果这不能解决错误按住选项键并再次单击菜单栏中的产品,那么您将在下拉菜单中看到清洁构建文件夹...单击它。或者您可以从appstore下载Watchdog应用程序。这个小助手会自动清理你的xcode项目。

#4


0  

You have to be very careful with swift. the language is very case sensitive so while using playground make sure all things are spaced out. The following code will NOT give you a syntax error but it will stop processing the rest of your code in playground :

你必须非常小心迅捷。该语言非常区分大小写,因此在使用游乐场时请确保所有内容都是间隔开的。以下代码不会给您一个语法错误,但它将停止处理操场中的其余代码:

for index in 1...5 {
    if index %2 !=0{
    continue
    }
println(index)
}

The error in the code above is in line 2. The code has to be written

上面代码中的错误在第2行。必须编写代码

    for index in 1...5 {
       if index % 2 != 0 {
       continue
       }
    println(index)
    }

Hope that answers your question :)

希望这能回答你的问题 :)

#1


36  

Make sure you haven't inadvertently added an error to your Playground code. Unfortunately, there is no inline notification of an error, and after an error is created, nothing in the Playground will update.

确保您没有无意中向Playground代码添加了错误。遗憾的是,没有错误的内联通知,并且在创建错误后,Playground中的任何内容都不会更新。

To help with this, open up the Assistant Editor (File > View > Assistant Editor > Show Assistant Editor), which should include a Console Output box. If there are any errors in your Playground, they will show up there. Once corrected, your Playground should hopefully update once more.

要解决此问题,请打开“助理编辑器”(“文件”>“视图”>“助理编辑器”>“显示助理编辑器”),其中应包括“控制台输出”框。如果您的游乐场中有任何错误,它们将显示在那里。一旦纠正,您的游乐场应该有希望再次更新。

That said, it can be a bit slow depending on the complexity of your Playground and its size.

也就是说,根据游乐场的复杂程度及其大小,它可能会有点慢。

#2


3  

This answer (Undeclared Type 'NSView' in Playground) did it for me (restarting Xcode and the machine didn't help):

这个答案(Playground中的Undeclared Type'NSView')为我做了(重启Xcode并且机器没有帮助):

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"

#3


1  

Had the same strange errors after upgrading to xcode 6 beta 6. For me the problem got fixed with a Product -> Clean. And if that does not fix the errors hold down option key and click again on Product in the Menubar then you will see in the dropdown menu Clean Build Folder... click on that. Or you could download Watchdog app from appstore. This little helper automatically cleans your xcode projects.

升级到xcode 6 beta 6之后有同样的奇怪错误。对我来说,问题已通过产品 - >清理修复。如果这不能解决错误按住选项键并再次单击菜单栏中的产品,那么您将在下拉菜单中看到清洁构建文件夹...单击它。或者您可以从appstore下载Watchdog应用程序。这个小助手会自动清理你的xcode项目。

#4


0  

You have to be very careful with swift. the language is very case sensitive so while using playground make sure all things are spaced out. The following code will NOT give you a syntax error but it will stop processing the rest of your code in playground :

你必须非常小心迅捷。该语言非常区分大小写,因此在使用游乐场时请确保所有内容都是间隔开的。以下代码不会给您一个语法错误,但它将停止处理操场中的其余代码:

for index in 1...5 {
    if index %2 !=0{
    continue
    }
println(index)
}

The error in the code above is in line 2. The code has to be written

上面代码中的错误在第2行。必须编写代码

    for index in 1...5 {
       if index % 2 != 0 {
       continue
       }
    println(index)
    }

Hope that answers your question :)

希望这能回答你的问题 :)