개발/아이오에스

swift 프로젝트를 스토리보드 없이(only code) 개발 셋팅하기 Set Up Project without Storyboard

dev.jake 2021. 3. 3. 14:38

https://medium.com/@yatimistark/removing-storyboard-from-app-xcode-14-swift-5-2c707deb858

 

Removing Storyboard From App [Xcode 14, Swift 5]

In this article, I will show you how to create a project without a storyboard in a few steps. Or rather, how to get rid of it, and code the…

medium.com

 

class AppDelegate: UIResponder, UIApplicationDelegate {

 

    var window: UIWindow?

 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        window = UIWindow()

        window?.rootViewController = ViewController()

        window?.makeKeyAndVisible()

    

        return true

    }

 

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

 

    var window: UIWindow?

 

 

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        

        guard let windowScene = (scene as? UIWindowScene) else { return }

 

        let window = UIWindow(windowScene: windowScene)

        window.rootViewController = ViewController()

        self.window = window

        window.makeKeyAndVisible()

    }

 

함수 scene을 위와 같이 rootViewController을 설정해준다

 

그리고 프로젝트에서 스토리보드 파일을 삭제한 후

 

 

 

 

위 사진처럼 Deployment info - Main interface를 빈칸으로 만든다.

 

 

위 사진처럼 Info.plist에서 Storyboard Name 부분을 삭제해준다.