Xcode 7 moves Playgrounds Console Output and breaks print() and println()

Xcode 7 Playgrounds behave differently than Xcode 6 Playgrounds – the user interface has changed, the Console Output has moved, and print() is different.

Playgrounds have the ability to show in-line code output, but don't be confused as it's not formatted the same way for println() and print() statements. Playgrounds "Quick Looks" provide a formatted view of your data, but if you want to see what it looks like, you need the Console Output. This moved back down to the Debug Area in Xcode 7 (from the Assistant Editor in Xcode 6).

Breaking println() and print behavior in Swift 2

Xcode 7 makes breaking changes to the behavior of the println() and print() methods. In Swift 2 you will be using print() to display text into the Console (Debug Area).

print() will append a newline to your text, which breaks the previous behavior where it didn't append newlines. If you want to prevent newlines you need to use the new optional parameter and pass in false.

// Swift 1.2
// Prints all on same line
for var i = 0; i < 10; i++ {
    print(i) // no newlines
//    println(i) // appends newline

// Swift 2
// Prints on separate lines, must use optional parameter for no newlines
for var i = 0; i < 10; i++ {
    print(i)  // appends newline
//    print(i, appendNewline: false)

Xcode 6 Playground Console Output

In order to see your Console Output from a print() statement in Xcode 6 you had to open the Assistant Editor (Venn Diagram icon) with the keyboard shortcut "Alt/Option + Command + Enter"

If you were lucky you would see output (assuming no code errors) and then if you accidentally closed the Console Output you would have to type something in the editor for the Playground and press Enter to get it to recompile and redisplay the Console Output.

Xcode 6 Playgrounds:&nbsp;Press Alt/Option + Command + Enter to see the Console Output

Xcode 6 Playgrounds: Press Alt/Option + Command + Enter to see the Console Output

Xcode 7 Playground Console Output

Xcode 7 changes how the Console Output works and makes this process less error prone and more streamlined. The Console Output is no longer displayed on the Assistant Editor, instead its below the standard editor in the normal Debug Area.

Press "Shift + Command + Y" to hide/show the Debug Area with the new Console Output, or you can press the tiny arrow button in the bottom left corner of your Playground in Xcode 7.

Xcode 7 Playgrounds: press Shift + Command + Y to see Console Output

Xcode 7 Playgrounds: press Shift + Command + Y to see Console Output

The good news is that the changes to Xcode 7 make the Playgrounds a more friendly code environment. It's easier to get to the Console Output without the clunky behavior of the Assistant Editor, which makes Playgrounds feel more like first class citizens.

Free Online Swift App Course

Subscribe to the iPhone Newsletter and learn how to make your first iPhone app in Swift with my free online iPhone app course.