Playgrounds in Xcode 10.1 highly unstable

I rarely use playgrounds and was planning to do a training on Swift basics for some co-workers.


I'm on macOS 10.14.1 with Xcode 10.1 (10B61)


Playgrounds though are highly unstable in that they will crash or complain that something isn't compilable when in fact it is when dropped into a Swift project. For the latter situation, here's what I mean:


If your playground has an obvious error, it is called out with the inlined error bar. For example:


let x = 3
x += 5  // ERROR: Left side of mutating operator isn't mutable: 'x' is a 'let' contstant


And, at the top of the playground window, you see a warning of "The playground could not continue running because the playground source did not compile successfully".


Problem though is I'm getting that warning when the code is valid. Not all the time though. At which point I close and re-open the playground and the issue sometimes goes away or persists. Sometimes I re-write the small code snippet and then it behaves.


I'm thus finding it difficult to narrow down the cause, but it seems like playgrounds are ending up in a bad state; thinking the code isn't complable and then producing that warning or crashing.


I have tried both run modes (Automatically Run and Manually Run) and get the same issues either way.

Replies

I think you have to close XCode and reopen, not only playground to clear everything.

There is no equivalent of Clean build folder for playground (because there is no build) !).


I tried the following in a playground, on macOS 10.13.6 with Xcode Version 10.1 beta 3 (10O45e)

let x = 3
x += 5
print(x)


It crashed (normal) with the message at top:

The LLDB RPC server has crashed. The crash is located in ~/Library/Logs/DiagnosticReports and has a prefix of 'lldb-rpc-server'. Please file a bug


I changed let to var and everything ran OK.

That's unfortunate about having to close Xcode. It's happening often enough to not be a reliable method of training. I will eventually file some bugs. For the training, will just stick with a simple Xcode project.

Did you try changing playground settings (XCode > File menu), notably the build system, to see if that improves ?

Didn't know about those settings, thank you. So far, plagrounds are much more stable when using the Legacy Settings.