AppDelegate 생성하기
AppDelegate.swift파일을 추가

아래 코드를 AppDelegate 파일에 추가
import Foundation
import UIKit
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
}

코드를 추가한 뒤 Project명 + App.swift 파일로 이동하여 다음 코드를 추가
import SwiftUI
@main
struct SwiftUISettingApp: App {
// 이부분을 추가
@UIApplicationDelegateAdaptor var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

SceneDelegate 생성하기
SceneDelgate.swift 파일을 추가

아래 코드를 SceneDlegate 파일에 추가
import Foundation
import UIKit
class SceneDelegate: NSObject, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
}
}

그 후 AppDelegate 파일에 다음 코드를 추가하면 설정 완료
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
sceneConfig.delegateClass = SceneDelegate.self
return sceneConfig
}

'iOS > iOS' 카테고리의 다른 글
| [iOS] SwiftUI에서 Info.plist 설정하기 (0) | 2023.03.02 |
|---|---|
| [iOS] info.plist에서LightMode, DarkMode 강제하기 (0) | 2023.03.02 |
| [iOS] CornerRadius를 활용하여 동그랗게 만들기 (0) | 2023.02.27 |
| [iOS] 시뮬레이터를 실행하지 않고 SwiftUI를 활용하여 UIKit 앱 미리보기 (0) | 2023.02.25 |
| [iOS] 화면 터치 시 키보드 내리기 (0) | 2023.02.14 |