class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
let store = Store.default
let map: GMSMapView = GMSMapView()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
guard GMSServices.provideAPIKey(AppConstants.Keys.googleMaps.rawValue) else { fatalError("Can not initialize Google Map services") }
print("Map: \(self.map)")
return true
}
在初始化GMSMapView时,代码会报告以下内容:
Thread 1: signal SIGABRT
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:0)
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
let store = Store.default
var map: GMSMapView?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
guard GMSServices.provideAPIKey(AppConstants.Keys.googleMaps.rawValue) else { fatalError("Can not initialize Google Map services") }
self.map = GMSMapView()
print("Map: \(self.map)")
return true
}
尝试像这样改变它
答案 1 :(得分:0)
检查控制台输出。您应该看到以下错误:
Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use
您正尝试在GMSService.provideAPIKey