I prefer to make a UIKit project without storyboard when coding alone.
However, as the version of Xcode has been updated and the UI has changed,
the method of configuring UIKit project without Storyboard also changed.
Just follow these steps.
(1) Make a new project.
(2) Remove Main.storyboard without hesitation.
- Click 'Move to Trash'.
(3) Move to Info.plist file, and dig into these step.
- Application Scene Manifest -> Scene Configuration -> Window Application Session Role -> Item 0 (Default Configuration) -> Storyboard Name
- Then you can find Main.
(4) Remove Main by clikcing '-(minus)' button.
(5) Move to project file, and click TARGETS(Not PROJECT), and click 'Info' tab.
- Then you can see 'Main storyboard file base name': Main
(6) Remove 'Main storyboard file base name' by clikcing '-(minus)' button.
(7) Now, open SceneDelegate.swift file
(8) Type these codes.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(windowScene: windowScene)
self.window?.rootViewController = ViewController()
self.window?.makeKeyAndVisible()
}
(9) Let's check ViewController.swift file
- As you see, I wrote 'self.view.backgroundColor = .systemYellow' to check this works propery.
- Now, it's time to build!
(10) Tada~ you nailed it! you made your project without Storyboard!
You can also check this project file on my GitHub.
'iOS > UIKit' 카테고리의 다른 글
[AutoLayout] Hugging과 Resistance (feat. intrinsic content size) (0) | 2023.04.24 |
---|---|
[iOS / UIKit] @IBDesignable과 @IBInspectable (0) | 2023.04.24 |
[iOS / UIKit] Notification과 Delegate으로 Data를 주고받는 것에 관하여 (0) | 2023.04.10 |
[iOS / UIKit] Delegate을 활용하여 ViewController간 Data 전달하기 (0) | 2023.04.10 |
[iOS / UIKit] Notification을 활용하여 ViewController간 Data 전달하기 (0) | 2023.04.10 |