Intro to SwiftUI

As we all know SwiftUI is here and it has completely changed development of apps, not only the UI but the way we code.

Basic Requirement For Development and Deployment:

  1. Xcode 11 or above
  2. iOS 13 or above
Here I have created a new project selecting SwiftUI as User Interface.





As we can see now the Left Pane consists of some new files like:
1. SceneDelegate.swift
2. ContentView.swift

On exploring AppDelegate.swift you will notice it has some methods we are not been aware of in the past like 
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) 

Heading towards the SceneDelegate.swift, this file is the place where we are connecting our scenes to the main window.
ContentView.swift has our scene for now, so the project has automatically linked it to window as shown in the screenshot.

Open the ContentView.swift file here you can see two "struct"s. To launch Automatic Preview Window click on right hand side Adjust Editor Options button, you can see a dropdown popover, out of this choose Canvas. Canvas will be launched and you may get to see "Automatic preview updating paused" with a button to Resume. Click this resume button and there we go.





Automatic Preview Window is the place where we can get instant reflection of our 
code. 
By default there is a Label known as Text in SwiftUI with text "Hello, World!" and you can see it in Automatic Preview Window without running your simulator.
Try changing the text to something else like "This is my SwiftUI Intro App" and the Xcode does the magic to reflects the textual change to the Canvas.


Comments

Popular posts from this blog

UITableView - Add or Remove Rows Dynamically (Objective C & Swift Source codes)

payUmoney Payment Gateway Integration in iOS App (Objective C)

Check Internet Connectivity Using AFNetworking 2.0