Hello Swift UI

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.

No alt text provided for this image


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".

No alt text provided for this image


  • Select iOS then Single View App from the template section.
No alt text provided for this image


  • Type "Hello Swift UI" in the product name and select User Interface to be "Swift UI".
No alt text provided for this image


  • Open "ContentView.swift" file. It will look like this: 
No alt text provided for this image


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.

No alt text provided for this image


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.


Abhishek A.

Technical Lead at GradRight Inc. | Building end-to-end solutions with a wide range of technologies

5 年

Nice Article ??

回复

要查看或添加评论,请登录

Dheeraj Bhavsar的更多文章

  • Fall in ?? with Recursion

    Fall in ?? with Recursion

    Hello everyone, in your journey of programming you would have used recursion at least once. Today, I want to introduce…

  • Generic Codables - Swift

    Generic Codables - Swift

    Hello everyone, I guess you all have faced this problem which I came across in the past few days and didn't found any…

  • Navigation and Networking in SwiftUI

    Navigation and Networking in SwiftUI

    Level: Intermediate-Advanced Hello everyone, today we are going to learn the basics of navigation, networking and image…

    1 条评论
  • Tap Me!

    Tap Me!

    Level: Beginner-Intermediate Hello guys, today we are going to create a reactive app, and you are going to learn a new…

  • Hello Swift UI vs Hello Flutter

    Hello Swift UI vs Hello Flutter

    Level: Beginner In the previous article, We've discussed Swift UI and we are going to compare Swift UI with Flutter…

    1 条评论

社区洞察

其他会员也浏览了