- 전체보기
- 상수와 변수
- CocoaPods 설치
- SwiftUI에서 AppDelegate 추가하기
- Multiple commands produce 에러
- NavigationStack iOS 16부터 지원
- 코드 자동 정렬 단축키
- var body: some View 안에서 print 하기
- framework not found GoogleMapsCore 에러
- Untrusted Developer 표시가 난다면
- Cannot find type 'CLLocationCoordinate2D' in scope 에러가 난다면
- VStack 글자 정렬
- AsyncImage 이용해서 외부 이미지 불러와서 보여주기
Swift - SwiftUI에서 AppDelegate 추가하기
조회수: 248
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
}
}