How to build iOS apps with swift UI?

On , by

SwiftUI is a user interface toolkit that allows us to design apps in a declarative way. Storyboards and XIB are severed well but they aren’t liked by everyone. They make it hard to move between code and visual layouts, and they rely on a system of connections using actions and outlets. SwiftUI removes all the disadvantages in an effective way

  1. New Declarative implementation that defines how the layout works
  2. Outlets and Actions bindings are checked at compile time
  3. Updating the UI preview automatically generates and updates a new code.

Requirements#requirements

Requires MacOS Catalina beta and XCode 11.

Right now it is only available on Beta stream. It will be available for the general public in mid-September.

Get Started with SwiftUI#get-started-with-swiftui

Some tips to start SwiftUI

  • In XCode 11, create a new project with the same usual previous procedure but make sure you check the SwiftUI checkbox.

  • In the project navigator, select ContentView.swift. SwiftUI is defined by two protocol one is View protocol and the second one declares a preview of that view. You should change the body of the content view depending on

    import SwiftUI
    
    
    struct ContentView: View {
    var body: some View {
       Text("Hello World")
    }
    }
    
    
    struct ContentView_Preview: PreviewProvider {
    static var previews: some View {
       ContentView()
    }
    }
  • In canvas, you can click “Resume” to get a preview. If the canvas isn’t available, click Editor > Editor and Canvas to get it.

  • Press Command and click on the Text component inside ContentView to get structured edit popover then select inspect for editing the text component. Use inspector for changing the text, adding font type, adding text color, etc

Conclusion#conclusion

The only disadvantage with SwiftUI is that you cannot use Objective-C. Other than that the dramatic simplification of UI creation with SwiftUI does a number of things for Apple. It makes coding much simpler and this is going to make the developer’s life much easier.

Share this article on Twitter or LinkedIn
Previous Blog Post: How we Automate Android App Distribution with Fastlane
Subscribe to Sudo vs Root

Our newsletter rolls out every month. No fluff. Pure content.

Comments and Discussions
Skcript https://www.skcript.com/svr/how-to-build-ios-apps-with-swift-ui/ https://www.skcript.com/svrmedia/heroes/how-to-build-ios-apps-with-swift-ui@1.5x.png