0
0
iOS Swiftmobile~10 mins

Creating a new iOS project in iOS Swift - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a basic SwiftUI app entry point.

iOS Swift
import SwiftUI

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            [1]()
        }
    }
}
Drag options to blanks, or click blank then click option'
ASceneDelegate
BAppDelegate
CContentView
DMainView
Attempts:
3 left
💡 Hint
Common Mistakes
Using AppDelegate or SceneDelegate here is incorrect because SwiftUI apps use a main view struct.
Using a name like MainView is possible but not the default in new projects.
2fill in blank
medium

Complete the code to declare the main app struct conforming to the SwiftUI App protocol.

iOS Swift
import SwiftUI

@main
struct [1]: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Drag options to blanks, or click blank then click option'
AMyApp
BMainApp
CAppMain
DSwiftApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like AppMain or SwiftApp which are not default.
Using MainApp is possible but not the default.
3fill in blank
hard

Fix the error in the code by completing the missing keyword to define the app's main entry point.

iOS Swift
import SwiftUI

[1]
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Drag options to blanks, or click blank then click option'
Aapp
B@main
C@UIApplicationMain
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' without @ causes syntax error.
Using @UIApplicationMain is for UIKit apps, not SwiftUI.
4fill in blank
hard

Fill both blanks to complete the SwiftUI view struct with a Text label.

iOS Swift
import SwiftUI

struct ContentView: View {
    var body: some View {
        [1]("Hello, world!")
            .[2]()
    }
}
Drag options to blanks, or click blank then click option'
AText
Bpadding
Cframe
DButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using Button instead of Text will change the UI behavior.
Using frame instead of padding changes layout differently.
5fill in blank
hard

Fill all three blanks to create a SwiftUI app with a main struct, a ContentView, and a Text label.

iOS Swift
import SwiftUI

@[1]
struct [2]: App {
    var body: some Scene {
        WindowGroup {
            [3]()
        }
    }
}

struct ContentView: View {
    var body: some View {
        Text("Welcome to my app!")
    }
}
Drag options to blanks, or click blank then click option'
Amain
BMyApp
CContentView
DUIApplicationMain
Attempts:
3 left
💡 Hint
Common Mistakes
Using @UIApplicationMain instead of @main for SwiftUI apps.
Mixing up the app struct name and the view struct name.