Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Tutorial "GuidedTour.playground" does nothing when opened in XCode6

Tags:

xcode

swift

This apple developer page introducing Swift has a link 3 paragraphs down for downloading the "GuidedTour.playground" file, which is supposed to allow you to follow along interactively with the tutorial. However, when I open this file in XCode6 Beta (I'm on a 2 month old MB pro, OSX 10.9.3), I see only this screen, which does not respond to mouse clicks or anything else (NOTE: "GuidedTour.playground" is the foreground window, there is another default playground window behind it):

Inert GuidedTour Window

How can I make it work?

Bonus Question: Probably unrelated, but when I play with the default playground I can't figure out where println statements are supposed to output to. They don't appear in the realtime righthand pane, or in the console at the bottom.

like image 566
Jonah Avatar asked Jun 02 '14 20:06

Jonah


4 Answers

Double click on the file: GuidedTour.playground All you will see is the document but it is interactive. Just make changes to the code and you will see the results change. To add a new line click on the end of an existing code line and press enter, you will get a new line to enter code.

If you want to see the entire Xcode environment:

  1. Menu View:Navigators:Show Project Navigator
  2. Menu View:Show Toolbar
  3. Menu View:Show Assistant:Show Assistant Editor (that is where the console output is)
  4. Click at the end of line 4 and press enter, that will create a line 5
  5. On line 5 add: println(myVariable)
  6. In a few seconds the output on the right will be updated:

Hello, world
50

Note: It is even more confusing when the instruction is read in iBooks on an iPad.

To get a new Playground is somewhat counterintuitive, you do not want a New:Project, instead: Menu File:New:File... and then choose a Template either iOS:Source:Playground or OSX:Source:Playground

like image 153
zaph Avatar answered Oct 14 '22 06:10

zaph


After many tries, I found out that when I download the file, it asks me if about the extension (in Chrome, sorry in French).

Choice of extension for Playground file

I always answered "Use .playground" and it resulted in an unusable file as listed by the question here. Finally I tried to use .zip extension, unarchive the file, and it works just as fine !

Hope it helps :)

like image 32
Tancrede Chazallet Avatar answered Oct 14 '22 05:10

Tancrede Chazallet


It's opening the playground in preview mode for some reason. Try this with the playground window in the foreground:

On the menu bar, choose Navigate -> Reveal in Project Navigator. The project navigator should open on the left side of the screen. Now right click on the playground file in the project navigator and choose Open as -> Playground.

like image 33
Ish Avatar answered Oct 14 '22 06:10

Ish


I think what you might be looking for is the assistant editor, when I showed that, I found my console output as well as timeline.

You also need to print something for it to show up on console output, except for the timeline, i didn't need to do any prints for that. I did notice that i had to fiddle with the assistant editors before the little symbol next to the output showed up for me to view the timeline.

like image 30
SunilK Avatar answered Oct 14 '22 07:10

SunilK