Hello Swift UI
Level: Beginner
Hello everyone, today we are going to create an application based on Swift UI. As a programmer, we all know that the very first program needs to be a "Hello World!" program. We are going to create something like your very first here. So let's get started
If you haven't downloaded the Xcode 11 (beta as of Sep 2019), download or update your existing app from the Apple App Store.
Now that all the tools we need are in the right place let us start building something cool and awesome.
Open Xcode and select "Create a new Xcode Project".
- Select iOS then Single View App from the template section.
- Type "Hello Swift UI" in the product name and select User Interface to be "Swift UI".
- Open "ContentView.swift" file. It will look like this:
Now, change the "Hello World" string to "Hello Swift UI" and run the application using "Run (Cmd + R)" command.
From
import SwiftUI struct ContentView: View { var body: some View { Text("Hello World") } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
To
import SwiftUI struct ContentView: View { var body: some View { Text("Hello Swift UI") } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
And BOOM ?? , your first app is ready with a "Hello Swift UI" label in it.
BONUS:
In the next article, I will be comparing Swift UI with Flutter which also follows the same "Declarative UI Syntax". Also, we will cover some of the fundamentals to get started with Swift UI
I hope you guys have enjoyed making your first iOS app using Swift UI. Have a great day. Thanks.
Technical Lead at GradRight Inc. | Building end-to-end solutions with a wide range of technologies
5 年Nice Article ??