harveytech
harveytech

Reputation: 207

Xcode 6 Beta / Swift - Playground not updating

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

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?

Upvotes: 15

Views: 13201

Answers (4)

Muhammad
Muhammad

Reputation: 133

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

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

Hope that answers your question :)

Upvotes: 0

Michael Markowski
Michael Markowski

Reputation: 31

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

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

Upvotes: 3

Fred
Fred

Reputation: 421

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.

Upvotes: 1

rcw3
rcw3

Reputation: 3034

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.

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.

Upvotes: 36

Related Questions