Bird
Raised Fist0
iOS Swiftmobile~15 mins

Project structure in iOS Swift - Mini App: Build & Ship

Choose your learning style10 modes available
Build: Simple Project Structure Overview
This screen shows a basic iOS app project structure with folders and files listed. It helps beginners understand where code and resources go.
Target UI
Project Structure

- MyApp
  - AppDelegate.swift
  - SceneDelegate.swift
  - ViewController.swift
  - Assets.xcassets
  - Info.plist
  - Base.lproj
    - LaunchScreen.storyboard
Display a list showing main project folders and files
Use indentation to show folder hierarchy
Use simple text labels for files and folders
Screen title should be 'Project Structure'
Starter Code
iOS Swift
import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack(alignment: .leading) {
            Text("// TODO: Add project structure list here")
                .padding()
        }
        .navigationTitle("Project Structure")
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
Task 1
Task 2
Task 3
Solution
iOS Swift
import SwiftUI

struct ContentView: View {
    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 6) {
                Text("MyApp")
                    .font(.headline)
                    .padding(.bottom, 4)
                Group {
                    Text("AppDelegate.swift")
                        .padding(.leading, 20)
                    Text("SceneDelegate.swift")
                        .padding(.leading, 20)
                    Text("ViewController.swift")
                        .padding(.leading, 20)
                    Text("Assets.xcassets")
                        .padding(.leading, 20)
                    Text("Info.plist")
                        .padding(.leading, 20)
                }
                Text("Base.lproj")
                    .font(.headline)
                    .padding(.top, 8)
                Text("LaunchScreen.storyboard")
                    .padding(.leading, 20)
            }
            .padding()
        }
        .navigationTitle("Project Structure")
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        NavigationView {
            ContentView()
        }
    }
}

This SwiftUI view uses a vertical stack to list the main folders and files of a simple iOS project. Indentation is done by adding padding to the left for files inside folders. The ScrollView ensures the content can scroll if the screen is small. The navigation title clearly shows the screen purpose. This structure helps beginners visualize where code and resources are placed in an iOS app project.

Final Result
Completed Screen
Project Structure

MyApp
  AppDelegate.swift
  SceneDelegate.swift
  ViewController.swift
  Assets.xcassets
  Info.plist
Base.lproj
  LaunchScreen.storyboard
User can scroll vertically if content is too long
Screen title 'Project Structure' is visible at top
Stretch Goal
Add icons next to folders and files to visually distinguish them
💡 Hint
Use SF Symbols with Image(systemName:) for folder and file icons and place them before the text labels

Practice

(1/5)
1. Which file in an iOS Swift project is primarily responsible for handling app launch and life cycle events?
easy
A. ViewController.swift
B. AppDelegate.swift
C. Assets.xcassets
D. Info.plist

Solution

  1. Step 1: Understand the role of AppDelegate.swift

    AppDelegate.swift manages app launch, termination, and state transitions.
  2. Step 2: Compare with other files

    ViewController.swift manages UI screens, Assets.xcassets holds images, Info.plist stores configuration.
  3. Final Answer:

    AppDelegate.swift -> Option B
  4. Quick Check:

    App life cycle = AppDelegate.swift [OK]
Hint: AppDelegate handles app start and life cycle events [OK]
Common Mistakes:
  • Confusing ViewController with AppDelegate
  • Thinking Assets.xcassets manages app life cycle
  • Assuming Info.plist handles launch events
2. Which of the following is the correct way to reference an image named "icon" stored in the Assets.xcassets folder in SwiftUI?
easy
A. Image("icon")
B. UIImage(named: "icon")
C. Image.asset("icon")
D. UIImageView("icon")

Solution

  1. Step 1: Identify SwiftUI image syntax

    In SwiftUI, images from assets are loaded using Image("imageName").
  2. Step 2: Differentiate UIKit and SwiftUI

    UIImage(named:) is UIKit, not SwiftUI; Image.asset and UIImageView("icon") are invalid syntax.
  3. Final Answer:

    Image("icon") -> Option A
  4. Quick Check:

    SwiftUI image = Image("icon") [OK]
Hint: Use Image("name") for assets in SwiftUI [OK]
Common Mistakes:
  • Using UIKit UIImage(named:) in SwiftUI code
  • Trying non-existent Image.asset method
  • Confusing UIImageView constructor with Image
3. Given this code snippet in an iOS project:
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
What is the purpose of this code in the project structure?
medium
A. To define app life cycle methods
B. To load images from Assets.xcassets
C. To create and display the main app window with a root view controller
D. To configure app permissions in Info.plist

Solution

  1. Step 1: Analyze UIWindow creation

    The code creates a UIWindow sized to the screen and sets its rootViewController.
  2. Step 2: Understand makeKeyAndVisible()

    This method makes the window visible and key for user interaction.
  3. Final Answer:

    To create and display the main app window with a root view controller -> Option C
  4. Quick Check:

    UIWindow setup = display main window [OK]
Hint: UIWindow with rootViewController shows main screen [OK]
Common Mistakes:
  • Confusing window setup with image loading
  • Thinking this code manages app life cycle
  • Assuming it edits Info.plist settings
4. You see this error in your iOS project: "SceneDelegate.swift not found". What is the most likely cause?
medium
A. The project was created without a SceneDelegate file, but the Info.plist expects it
B. Assets.xcassets folder is missing
C. AppDelegate.swift is empty
D. Storyboard file is corrupted

Solution

  1. Step 1: Understand SceneDelegate role

    SceneDelegate manages UI scenes in multi-window apps, required if Info.plist references it.
  2. Step 2: Identify mismatch

    If SceneDelegate.swift is missing but Info.plist expects it, app will error.
  3. Final Answer:

    The project was created without a SceneDelegate file, but the Info.plist expects it -> Option A
  4. Quick Check:

    Missing SceneDelegate file = Info.plist mismatch [OK]
Hint: Check Info.plist and project files match for SceneDelegate [OK]
Common Mistakes:
  • Blaming missing assets for SceneDelegate error
  • Assuming empty AppDelegate causes this error
  • Thinking storyboard corruption causes SceneDelegate error
5. You want to organize your iOS project so that all UI layouts are stored separately from code files. Which folder should you use to store these layouts?
hard
A. Models folder
B. Assets.xcassets folder
C. Supporting Files folder
D. Storyboard folder

Solution

  1. Step 1: Identify UI layout storage

    Storyboards hold UI layouts visually designed for screens.
  2. Step 2: Differentiate other folders

    Assets.xcassets holds images, Supporting Files hold config files, Models hold data structures.
  3. Final Answer:

    Storyboard folder -> Option D
  4. Quick Check:

    UI layouts = Storyboard folder [OK]
Hint: Store UI layouts in Storyboard folder, not assets or models [OK]
Common Mistakes:
  • Putting UI layouts in Assets.xcassets
  • Confusing Supporting Files with UI storage
  • Storing layouts in Models folder
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard