🔨Xcode Project Setup

Fall 2023 | Vin Bui

Note that we will provide you with the setup in the assignments. However, this will be helpful for when you create a project on your own such as the Hack Challenge.

Create a New Project

  1. Go to File > New > Project

  2. Select the iOS tab, choose App and click Next

  3. You can leave everything alone except for the following:

    1. Product Name: Enter the name of the app

    2. Interface: Storyboard (yes, keep Storyboard even though we won’t be using it)

    3. Language: Swift

    4. Uncheck “Use Core Data”

    5. Uncheck “Include Tests”

  1. Choose a directory for your project and hit Create

Switch to Programmatic Layout

  1. To utilize programmatic Auto Layout, delete Main.storyboard from the Navigator in Xcode. Right click > Delete > Move to Trash

  1. Press CMD + SHIFT + F or click on the 🔎 icon in the Navigator. Look up storyboard and you should see something like this:

  1. Click on the red box above and look up storyboard in the filter search bar. Select UIKit Main Storyboard File Base Name and his Backspace on your keyboard to delete it.

  1. Now select the blue box from step 2, or go to Info.plist and delete Storyboard Name by clicking on the minus (-) symbol.

Setup SceneDelegate.swift

Add the following code to the function scene in SceneDelegate.swift

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // 1. Capture the scene
    guard let windowScene = (scene as? UIWindowScene) else { return }
    // 2. Create a new UIWindow and pass in a UIWindowScene
    let window = UIWindow(windowScene: windowScene)
    // 3. Create a view hierarchy programmatically
    let rootVC = ViewController()
    let navController = UINavigationController(rootViewController: rootVC)
    // 4. Set the navigation controller as the window's root view controller
    window.rootViewController = navController
    // 5. Set the window and call makeKeyAndVisible()
    self.window = window

Last updated