Blog

How to Build An App – 2019

In this article we will be creating an iOS application. Our application is designed to be simple so that we can learn the basics of how to build one.
For this tutorial, make sure you have XCode installed in your machine. If you do not have XCode installed, follow this link to download it. After you download XCode, follow the instructions and install it.

After you install the XCode, open it and go to File > New > Project…

XCode create a new project screen

On the presented window make sure iOS tab is selected. In the Application section, select Single View App then click Next. In the Product Name field, give your product a name, make sure Use SwiftUI is selected, then click Next. Save your project anywhere on you mac then click Create

Xcode new SwiftUI project

Congratulations! You have created a new application. From the top menu, go to Product > Run to see the app running in simulator. Simulators are used to test how your app behaves before you can submit them to AppStore. Our app doesn’t do much as it is. You should see a Hello World in the center of the simulator.

This is so cool!

On the left side of XCode, you have the Project Navigator panel that lists all of your app files, images, and resources. In that file list you should see a file named ContentView.swift. Select that file to open it in the editor. The code you see is responsible for displaying Hello World in the simulator. You can go ahead and change the text from Hello World to anything, make sure your text is between quotation marks. In my example I typed, This is so cool! in quotation marks. Run your app by going to Product > Run to see the new text displayed in the simulator.

SwiftUI

We will use SwiftUI to build our app. What is SwiftUI? Apple announced it recently at their annual developer conference in San Francisco, and this is how they describe it:

SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With a declarative Swift syntax that’s easy to read and natural to write…

https://developer.apple.com/xcode/swiftui/

In a nutshell, SwiftUI is a new framework to create user interfaces in more declarative and succinct way, hence the suffix UI. Let’s go back to our project and see how SwiftUI makes our project easy to build. We will make an app that will have a button to toggle an image on the screen.

Click on ContentView.swift to open it in the editor. Remove everything inside the body property. You should have the code similar to below example.

import SwiftUI
struct ContentView: View {
var body: some View{

}
}

Emrah UsarHow to Build An App – 2019