Generally, 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 platforms 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 platform 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 the development of iOS applications using swift. We can download Xcode editor from the 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 to download Xcode from the Apple app store open the app store in the system and search for Xcode in the search bar and download it. Following is the screenshot which shows how to search Xcode and download from the app store.
In case if you want to download the Xcode from a website, we need to sign up for 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 on the 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 the Xcode editor.
If you open and login to the apple website by using the 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 a simple "Hello World" program in swift with example. for that Go to Search which is in the 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 the welcome window click on the first option “Get started with a playground” to create a project in swift.
After selecting “Get started with a playground” a new window will open in that we need to give the project name as “Hello World” and select platform as “iOS” and click on Next like as shown below.
Once we click on the 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 the project then click on Create button like as shown below
Once we click on Create button new project will create and the 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 the 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 the swift playground to write and execute programs based on our requirements.