SwiftUI — Create New Project

Rohanchhatbar
3 min readDec 30, 2020

Create a New Project and Explore the Canvas

In this tutorial, we will create a new project understand the entry point of App

SwiftUI is the new UI framework developed by Apple. It provides a new API allowing you to write code that works on all Apple platforms. Yes you heard right! All Apple platforms: iOS, iPadOS, watchOS and tvOS!

Create a New Project and Explore the Canvas

Create a new Xcode project that uses SwiftUI. Explore the canvas, previews, and the SwiftUI template code.

Step 1: Open Xcode and either click “Create a new Xcode project” in Xcode’s startup window, or choose File > New > Project.

Step 2 : In the template selector, select iOS as the platform, select the App template, and then click Next.

Step 3 : Enter “your project name here” as the product name, select “SwiftUI” for the interface and “SwiftUI App” for the life cycle, and click Next. Choose a location to save the project on your Mac.

Step 4 : In the Project navigator, select {your-project-name}App.swift.An app that uses the SwiftUI app life cycle has a structure that conforms to the App protocol.The structure’s body property returns one or more scenes, which in turn provide content for display.
The @main attribute identifies the app’s entry point.

LandmarksApp.swift (Step 4)

Step 5: In the Project navigator, select ContentView.swift.

By default, SwiftUI view files declare two structures. The first structure conforms to the View protocol and describes the view’s content and layout. The second structure declares a preview for that view.

Step 6 : In the canvas, click Resume to display the preview.

If the canvas isn’t visible, select Editor > Canvas to show it.

Step 7 : Inside the body property, change “Hello, World!” to a greeting for yourself.

As you change the code in a view’s bodyproperty, the preview updates to reflect your changes.

This article is to get you started — there is way more to come! You can follow me here on Medium

I am really happy you read my article! If you have any suggestions or improvements of any kind let me know! I’d love to hear from you! 😊

--

--