Swift Language Your first program in Swift on a Mac (using a Playground)


Example

From your Mac, download and install Xcode from the Mac App Store following this link.

After the installation is complete, open Xcode and select Get started with a Playground:

enter image description here

On the next panel, you can give your Playground a name or you can leave it MyPlayground and press Next:

enter image description here

Select a location where to save the Playground and press Create:

enter image description here

The Playground will open and your screen should look something like this:

enter image description here

Now that the Playground is on the screen, press + cmd + Y to show the Debug Area.

Finally delete the text inside Playground and type:

print("Hello world")

You should see 'Hello world' in the Debug Area and "Hello world\n" in the right Sidebar:

enter image description here

Congratulations! You've created your first program in Swift!