SceneDelegate ์ญ์ ํ๋ ๋ฒ์ ์์๋ณด์
SceneDelegate๋ iOS 13๋ถํฐ ์๋ก ์ถ๊ฐ๋์ด Xcode11๋ถํฐ SceneDelegate๊ฐ ๊ธฐ๋ณธ iOS ์ฑ ํ๋ก์ ํธ ํ ํ๋ฆฟ์ผ๋ก ์๋์ถ๊ฐ๋ฉ๋๋ค.
๊ทธ๋ฅ ์ง์ฐ๊ณ ๋น๋ํ๋ฉด ๊ฒ์ ํ๋ฉด์ด ๋์ค๊ธฐ ๋๋ฌธ์,
๋ค์ ๊ณผ์ ์ ๋ฐ๋ฅด๋ฉด ํ.์ค.ํ.๊ฒ. ์ญ์ ํ ์ ์์ต๋๋ค๐ป
1. Info.plist์์ Application Scene Manifest ์ญ์
์ญ์ ์ํ๋ ๊ฒฝ์ฐ ์๋ ์๋ฌ๋ฐ์ >>
13:23:49.218883+0900 FunctionList_Objc[45720:3662506] [SceneConfiguration] Info.plist configuration "Default Configuration" for UIWindowSceneSessionRoleApplication contained UISceneDelegateClassName key, but could not load class with name "SceneDelegate".
2. ํ๋ก์ ํธ์์ SceneDelegate.swift ํ์ผ ์ญ์
3. AppDelegate.swift ๋ด UISceneSession ๊ณผ ๊ด๋ จ๋ ๋ ๋ฉ์๋ ์ญ์
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
4. SceneDelegate.swift ๋ก ์ฎ๊ฒจ์ง window ํ๋กํผํฐ๋ฅผ AppDelegate.swift์ ์ถ๊ฐ
// AppDelegate.swift
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ํ๋์ ์ฌ์ ํด๋น๋๋ ์๋์ฐ ์์ฑ
self.window = UIWindow(windowScene: scene as! UIWindowScene)
// ๊ฐ์ฒด ์์ฑ
let vc = UINavigationController()
vc.view.backgroundColor = .white
// ์๋์ฐ์ ๋ฃจํธ ๋ทฐ ์ปจํธ๋กค๋ฌ๋ก ๋ฑ๋ก
self.window?.rootViewController = vc
return true
}
window ์ถ๊ฐํ์ง ์๋ ๊ฒฝ์ฐ!!
* reason: '-[AppDelegate setWindow:]: unrecognized selector sent to instance 0x600000f20080' ์๋ฌ ๋ฐ์