-
[iOS] SceneDelegate/UISceneSession 가장 깔끔하게 없애는 방법 - 'UISceneSession' is only available in iOS 13.0 or newerI'm a Developer/iOS & macOS 2020. 2. 4. 11:13
지난 WWDC2019에서는 SwiftUI와 더불어 iOS 13으로의 업데이트와 함께 새로운 프로젝트를 생성할 때,
SceneDelegate를 무조건 생성하게 됩니다.
하지만 아직까지는 iOS13 버전보다 낮은 버전을 지원해야할 때이고, SwiftUI를 쓰지않고 개발하는 경우가 더 많기 때문에(또 인터넷에 있는 대부분의 예제들이 SceneDelegate없이 동작하기 때문에)
이를 제거하고 기존의 방법대로 프로젝트를 가동시키는 것을 설명하고자 합니다.
순서는 다음과 같습니다.
- SceneDelegate 제거
- AppDelegate에 window객체 추가하기
- AppDelegate에서 UISceneSession 관련 메소드 제거
- .plist에서 SceneDelegate관련 속성 제거
--
1. SceneDelegate 제거
프로젝트 파일중 SceneDelegate를 제거해주세요.
(var window: UIWindow?를 미리 복사해도 좋습니다.)
2. AppDelegate에 window객체 추가
복사해 놓은 window 객체 선언문을 AppDelegate에 붙여넣습니다.
복사를 못했다면 아래 코드블럭을 복사하세요
var window: UIWindow?
3. AppDelegate에서 UISceneSession 관련 메소드 제거
AppDelegate에서 "// MARK: UISceneSession Lifecycle"라고 써있는 주석 밑에 있는 다음의 메소드 2개를 지우세요.
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>)
4. .plist에서 SceneDelegate관련 속성 제거
.plist에 정의된 Application Scene Manifest 속성을 제거하세요.
-----
정상적으로 작동됩니다~!
'I'm a Developer > iOS & macOS' 카테고리의 다른 글
Notification (0) 2020.03.02 [iOS] 안전한 로그인을 위한 키체인(Keychain)과 FaceID/TouchID - 원문 해석본 (0) 2020.02.04 API Timeout 처리 (with. RxSwift) (0) 2020.01.15 Xib(Nib)으로 outlet변수를 연결할 때, 크래시가 발생하는 현상 (0) 2020.01.15 [CocoaPods Library pod repo push 에러] The validator used Swift 3.2 by default because no Swift version was specified. (0) 2019.04.04