티스토리 뷰

728x90
반응형

1. Main 스토리보드 지우기

- 코드로만 UI를 구현한 경우, 스토리보드가 있으면 읽는 사람에게 혼동을 줄 수 있음

 

2. Main Interface 삭제

 Xcode 14버전 이전 

- 프로젝트 앱 > TARGETS > 프로젝트명 > General > Deployment Info > Main Interface > Main

- Main 글자를 지워주고 Enter 해주면 끝 

 

 Xcode 14버전  

프로젝트 앱 > TARGETS > 프로젝트명 > Info > Custom iOS Target Properties > Main storyboard file base name

- Main storyboard file base name을 찾아서 ⛔️ 버튼 눌러주면 삭제됨 

 

3. Stroyboard Name 삭제

- Info > Stroyboard Name

- Stroyboard Name을 찾아서 ⛔️ 버튼 눌러주면 삭제됨

 

4. window 설정

- Stroyboard만 지운다고 해서 바로 뷰가 나오는 것이 아님

- 아래 코드 추가해야 함

 

 iOS 13버전 이후 

// SceneDelegate.swift

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() // ViewController 인스턴스 생성해서 추가
        window.makeKeyAndVisible()
        
        self.window = window
    }
    
    // ...
  
  }

 

 iOS 13버전 이전 

// AppDelegate.swift

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
		
        // 여기 추가!
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = ViewController() // ViewController 인스턴스 생성해서 추가
        window?.makeKeyAndVisible()

        return true
    }
    
    // ...
}

 

 

이제 빌드하면 스토리보드 없이 화면이 잘 나옴! 

728x90
반응형

'[iOS] > ㄴSwift' 카테고리의 다른 글

[Swift] SwiftUI로 Kakao Map 보여주기  (1) 2023.09.14
[Swift] SwiftUI로 Facebook Login 구현하기  (0) 2023.01.21
[Swift] JSON 사용하기1  (0) 2022.06.14
댓글