3

Using a playground file in Xcode 6 beta, I am trying to get an output in the console for the println command. I have written println("test"), opened the Assistant Editor (View\Assistant Editor\Show Assistant Editor) and see that little window named "Console output", but still I get nothing. I have also tried to close and restart Xcode.

What am I doing wrong?

6
  • Try restart Xcode and try again. Commented Jun 25, 2014 at 15:09
  • Yep, I've run into this myself and I just don't think the playground supports sending output to the standard output. Fortunately, it's easy to create a console app to test stuff, which is what I did. Commented Jun 25, 2014 at 15:10
  • Is that the only code you have in your playground? Commented Jun 25, 2014 at 15:14
  • @connor Yes, I have exactly what x43x61x6 has written below. Commented Jun 25, 2014 at 15:27
  • 1
    It seems to be hit and miss right now. Remember you can always just use our old friend NSLog as well. Commented Jun 25, 2014 at 17:49

5 Answers 5

2

In recent Versions of Xcode, like Beta 6, the println() result will be displayed in the sidebar on the right.

No need for Assistant Editor anymore.

But you need to install new Beta Versions manually.

Sign up to request clarification or add additional context in comments.

Comments

1

1) Close the Assistant Editor

2) Quit Xcode

3) Reopen the playground file

4) Open Assistant Editor (Command+Option+Enter or View/Assistant Editor/Show Assistant Editor)

Now it should show the logs.

1 Comment

okay... just reassuring to whether you closed the assistant editor before quitting xcod, because the log will not reflect if you quit the xcode without closing the assistant editor. I hope you did that 2-3 times. Worked in my case !!!
1

If you're using Swift 2, you can only use print() to write something to the output.

Apple has combined both println() and print() functions into one.

Here is an example to print on a single line (use the optional appendNewLine: argument):

print("Hello new Print with new line", appendNewline: false)

Otherwise print defaults to adding a carriage return at the end of each line.

print("Hello new Print with new line")

3 Comments

why would one use that .. when you can only add 2 more alphabets. Laziness wins over this monstrous func call.
Please note that in swift 2, the appendNewLine parameter is true by default, so you only need to pass it if you want it to be false.
Thanks @PedroSilva Now I've edited my answer! You were right!
1

For others who face the issue, they might have closed the area where messages are shown.

If you are using print() ( from Swift 2.0 ) to print and see debug messages, do this.

Click on View on top, Go To Debug Area and click Activate Console.

This will open the area where debug messages are printed.

Comments

0

Which version are you using? Xcode 6 beta 2? OS X 10.10?

If so, it should work.

enter image description here

2 Comments

I have exactly what you have written. Do not run Yosemite though, but should not make any difference. Or should it?
Xcode 6 crashes all the time on my 10.9.3, so I end up install 10.10 on one of my Macs as a develop machine for Swift. It's hard to say there's a difference or not, only Apple and God knows. And I noticed that, even with the same 10.9 SDK, the one compiled on 10.10 won't run on 10.9, but when you do it on 10.9, it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.