뭐 아무것도 모르고 그냥 프로젝트 만들고 시작해서 머리 깨져가면서 배우는 거지 뭐 ㅎㅎ
google map api 발급받고 키 설정하려는데, appdelegate 파일이 없어서 찾아봤다
uikit vs swiftui 차이점에 대한 좋은 글: velog.io/@altmshfkgudtjr/SwiftUI-ScenePhase
위의 글로 간단하게 차이점을 파악했고, 프로젝트 생성할 때 swift ui app 으로 생성해서 그렇다 (ios 14 이후 지원)
(swift ui 소스가 많진 않은데 그래도 미래를 위해서 계속 이렇게 하기로 하고) delegate 연결은 이렇게 한다고 한다.
앱이름App.swift
import SwiftUI
import GoogleMaps
let googleApiKey = "api key 여기에 입력해주세요"
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
print(">> your code here !!")
GMSServices.provideAPIKey(googleApiKey)
return true
}
}
@main
struct 앱이름App: App {
@StateObject var viewRouter = ViewRouter()
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView(viewRouter: viewRouter)
}
}
}
references
medium.com/@vatsal_manot/appdelegate-in-swiftui-2-e88fa6301e4d
AppDelegate in SwiftUI 2
With SwiftUI 2.0, UIApplicationDelegate is a thing of the past… well, maybe not. While the new App protocol and friends provide great…
medium.com
stackoverflow.com/questions/62538110/swiftui-app-life-cycle-ios14-where-to-put-appdelegate-code
728x90
반응형
'개발' 카테고리의 다른 글
ios gitignore setting (0) | 2021.04.12 |
---|---|
ld: framework not found Pods (4) | 2021.04.05 |
ios pod install in mac m1 (0) | 2021.04.04 |
ios 시작 (0) | 2021.03.24 |
AR Kit 다운로드 (0) | 2021.02.26 |