๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐ŸŽ iOS/iOS Application

[iOS] SceneDelegate ์‚ญ์ œํ•˜๊ธฐ

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' ์—๋Ÿฌ ๋ฐœ์ƒ

 

 

728x90
๋ฐ˜์‘ํ˜•