Swift - SwiftUI에서 AppDelegate 추가하기
조회수: 63
AppDelegate.swift에 구글 지도 API를 넣으라고 하는데 AppDelegate.swift가 보이지 않는다.
예전에 작업한 프로젝트에는 AppDelegate.swift가 있다.
검색을 해보니 직접 매인 App 파일 안에 코드를 작성해야 한다고 한다.
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
그리고
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("Your code here")
return true
}
}
넣으라고 한다.
예전에 작업한 프로젝트에는 AppDelegate.swift가 있다.
검색을 해보니 직접 매인 App 파일 안에 코드를 작성해야 한다고 한다.
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
그리고
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print("Your code here")
return true
}
}
넣으라고 한다.
@main
struct sangseektravelmapApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
GMSServices.provideAPIKey("Your API 키 넣기")
return true
}
}