Xcode 10 Beta Playgrounds


It seems like Xcode 10 does not allow for variables to be declared uninitialized in playgrounds. This doesn’t dramatically change the book for me, but wanted to bring it up for your reference.


I also noted this new behavior in the release version Xcode 10.

More specifically, in a playground, if you enter something like:

var myInt: Int

you will see this error printed in the debug area:

error: variables currently must have an initial value when entered at the top level of the REPL
var myInt: Int

The error only occurs when you have a playground set to “Manually Run” (which I believe is the default “Execute Playground” option for a newly created playground in Xcode 10).

If you change the “Execute Playground” option to “Automatically Run” the above code will be accepted and you will not get the error.

You can choose the “Execute Playground” run option by a click-and-hold on the triangle (run) icon at the top left of the debug area (which is at the bottom of the playground window).