Generall,y in swift we use playground interface to do programming for that we need to install XCode Editor which is the built-in free editor of Apple and it’s used for any type of development for apple platform like OSX Software’s, iPhones App and etc.
Once we are familiar with swift concepts then we can use Xcode IDE to develop applications for any type of apple platforms like OSX Software’s, iPhones App, Mac, etc.
The basic requirement to install Xcode editor, we should have minimum Apple Laptop or Mac Computer for development of iOS applications using swift. We can download Xcode editor from Apple website or Apple app store and this editor is completely free we don’t need to pay anything for Apple.
In case if you want download Xcode from Apple app store open the app store in system and search for Xcode in search bar and download it. Following is the screenshot which shows how to search Xcode and download from app store.
In case if you want to download the Xcode from website, we need to sign up the Apple Developer Program which is free and download the Xcode editor but remember when we are going to publish our application Apple will charge 99$.
Once we sign up in Apple website with Apple account and go to the Downloads section and download the Xcode Editor. Use this Download Xcode Editor URL to login and download Xcode editor.
If you open and login to the apple website by using above URL go to the downloads section, you will find Xcode editor to download like as shown below
After download click on Xcode.dmg file, just drag the Xcode and drop into the Application folder like as shown below and our Xcode installation will take 2 to 3 minutes.
Now we will see how to write simple "Hello World" program in swift with example. for that Go to Search which is in top right side at menu bar --> Click on it and search for “Xcode” and open it like as shown below.
Once we open Xcode the welcome window will open like as shown below. In welcome window click on the first option “Get started with a playground” to create project in swift.
After selecting “Get started with a playground” a new window will open in that we need to give project name as “Hello world” and select platform as “iOS” and click on Next like as shown below.
Once we click on Next button new dialog will open in that we need to select the location to save our project. Once you select the location to save project then click on Create button like as shown below
Once we click on Create button new project will create and playground window will open like as shown below.
Generally swift playground window will contain both input and output windows side by side like as shown above.
Following is the simple “Helloworld” code written in swift playground (Left Hand Side).
The above program will display the result like as shown below (Right Hand Side).
This is how we can use swift playground to write and execute programs based on our requirements.