> For the complete documentation index, see [llms.txt](https://ios-course.cornellappdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-course.cornellappdev.com/resources/tool-guides/xcode-project-setup.md).

# Xcode Project Setup

{% hint style="info" %}
**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.**
{% endhint %}

### 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”

<figure><img src="/files/agJ18arQP9vdqLKVCQJV" alt=""><figcaption></figcaption></figure>

4. 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**

<div><img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/18baf9ff-c6cd-467f-8041-e44fe6bfd024/Untitled.png" alt="Untitled"> <figure><img src="/files/qpzvBmE5CyTSnQX22rQM" alt="" width="267"><figcaption></figcaption></figure></div>

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

<figure><img src="/files/2myx2jAZtkahLwpiKakA" alt="" width="188"><figcaption></figcaption></figure>

3. Click on the <mark style="color:red;">red box above</mark> 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.

<figure><img src="/files/vSPP8dJh8VimP5ysjgwT" alt=""><figcaption></figcaption></figure>

4. Now select the <mark style="color:blue;">blue box</mark> from step 2, or go to `Info.plist` and delete `Storyboard Name` by clicking on the minus (-) symbol.

<figure><img src="/files/vBzNzB2jcjB8yeBLGqUl" alt=""><figcaption></figcaption></figure>

### Setup `SceneDelegate.swift`

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

```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
    window.makeKeyAndVisible()
}
```
