SwiftUI Hello World

Minimal SwiftUI example

If you’re eager to get your feet wet with SwiftUI the minimal sample may look like this:

import SwiftUI

struct App: View {
    var body = Text("Hello World")
}

But hold your horses

Unless you’re Swift developer you’re unlikely to have all the required software. So the challenge now is how to get minimal number of required components to be able to try SwiftUI.

For me, having:

The only requirement turned to be the Xcode 11. Once I had the 7G download complete I was able to get the sample working.

SwiftUI in Playground

Getting the sample working in Playground(Xcode 11) turned to be straightforward:

import PlaygroundSupport
import SwiftUI

struct App: View {
var body = Text("Hello World")
}

PlaygroundPage.current.liveView = UIHostingController(rootView: App())

Despite missing live reload functionality that requires OSX 10.15 it’s a good foundation for exploring SwiftUI.

swift ui in playground

References

Related Posts
More Posts…
Monotonic Time, or Perfect model vs Imperfect Reality
Comments
see comments↓