How to print to console using swift playground?

后端 未结 7 629
余生分开走
余生分开走 2020-11-27 03:57

I have been following the Apple Guide for their new language swift, but I don\'t understand why the bar on the right is only showing \"Hello, playground\" and not \"Hello, w

7条回答
  •  误落风尘
    2020-11-27 04:23

    In Xcode 6.3 and later (including Xcode 7 and 8), console output appears in the Debug area at the bottom of the playground window (similar to where it appears in a project). To show it:

    • Menu: View > Debug Area > Show Debug Area (⌘⇧Y)

    • Click the middle button of the workspace-layout widget in the toolbar

      workspace layout widget

    • Click the triangle next to the timeline at the bottom of the window

      triangle for console

    Anything that writes to the console, including Swift's print statement (renamed from println in Swift 2 beta) shows up there.


    In earlier Xcode 6 versions (which by now you probably should be upgrading from anyway), show the Assistant editor (e.g. by clicking the little circle next to a bit in the output area). Console output appears there.

提交回复
热议问题