Jonah
Jonah

Reputation: 16202

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

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.

Upvotes: 24

Views: 22471

Answers (7)

Darren
Darren

Reputation: 1427

I downloaded GuideTour.playground today (10/19/2014) and none of the above solutions worked for me. It turned out that there were errors in the code that needed Xcode 6.1 instead of Xcode 6.0. I downloaded XCode6.1 and the sample then worked.

Upvotes: 1

DanDoes
DanDoes

Reputation: 1

I also had this problem, where nothing was showing up on the side.

When I first opened it up, they worked fine, then one time after I added some code to test, the sidebar lines went grey and stayed that way. After closing and opening the file, the bar was just blank.

For me, the problem was with Xcode - looks like instead of showing me an error, it just crashed:

Playground execution failed: error: code after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedwill never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedwill never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executedcode after 'return' will never be executed:108:1: error: variable 'largestKind' used before being initialized

Anyway all I had to do to get them to work again was to remove the offending lines!

As this is clearly a problem with Xcode, I suspect it will be fixed before it is out of beta.

To answer your bonus question: Cmd+Alt+Enter to show output

(This is how I saw the above error too, so having that output area open while you work can be quite useful)

Upvotes: 0

zaph
zaph

Reputation: 112857

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

Upvotes: 18

Muhammad Asad
Muhammad Asad

Reputation: 1013

I came across similar issue. When you download Xcode beta 6, it does not overwrite your existing Xcode version 5.1 or whichever. So your computer has 2 IDE. Xcode beta 6.0 and older version. So, if you have included myplayground in your Xcode 6, and then came back and open the same project(BUT WHEN YOU OPEN PROJECT OR XCODE, BY DEFAULT IT WILL OPEN 5.1). So, in Xcode 5.1 you will see myplaygroundk but you won't able to play with it. So make sure that you open Xcode 6.0(BETA) from launchpad.

Upvotes: 0

Tancrede Chazallet
Tancrede Chazallet

Reputation: 7245

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 :)

Upvotes: 12

SunilK
SunilK

Reputation: 157

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.

Upvotes: 1

Ish
Ish

Reputation: 21

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.

Upvotes: 2

Related Questions