当我尝试初始化地图时,应用程序崩溃了。我在 UIkit 中也遇到同样的问题。 我尝试清理 Pod、更新 Pod 和清理项目。上周它工作正常,不是开玩笑
iOS:16.2 iPhone:14+ 谷歌地图 7.4.0
代码
func makeUIView(context: Context) -> GMSMapView {
let camera: GMSCameraPosition = .init(latitude: currentLocation.latitude, longitude: currentLocation.longitude, zoom: 16.0)
crash here --> let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.delegate = context.coordinator
mapView.isMyLocationEnabled = true
context.coordinator.mapView = mapView
self.updateCircle(mapView: mapView)
return mapView
}
报告文件
Date/Time: 2024-02-27 20:42:46.7377 -0600
Launch Time: 2024-02-27 20:36:28.3196 -0600
OS Version: macOS 13.4.1
Release Type: User
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 17
Thread 0:: Dispatch queue: com.apple.main-thread
0 ??? 0x1491f5f50 ???
1 ??? 0x1491f5da0 ???
2 app-name 0x105075b60 __InstrumentSessionWithConfigurationDelegateDelegateQueue_block_invoke + 48
3 app-name 0x11311ee34 -[GMSx_GTMSessionFetcher createSessionWithDelegate:sessionIdentifier:] + 569
4 app-name 0x11311dedb -[GMSx_GTMSessionFetcher beginFetchMayDelay:mayAuthorize:mayDecorate:] + 2019
5 app-name 0x1130de6b0 GMSAllSDKCheckForUpdatesImpl + 281
6 libdispatch.dylib 0x1611fef5b _dispatch_client_callout + 8
7 libdispatch.dylib 0x1612005b5 _dispatch_once_callout + 66
8 app-name 0x1130387eb -[GMSServices initWithDisplayLink:resourceCache:clearcutClient:dataURL:cachesURL:options:] + 3558
9 app-name 0x11301844f invocation function for block in CompleteInit(GMSAsyncInitServices*) + 241
10 app-name 0x1130181e3 CompleteInit(GMSAsyncInitServices*) + 345
11 app-name 0x11301825b -[GMSAsyncInitServices services] + 67
12 app-name 0x11303758d +[GMSServices sharedServicesSync] + 136
13 app-name 0x113023c89 -[GMSMapView initWithFrame:] + 40
14 app-name 0x104d79b6d @nonobjc GMSMapView.init(frame:) + 61
15 app-name 0x104d76f2a GMSMapView.__allocating_init(frame:) + 74
16 app-name 0x10b442d26 AddressMapKit.makeUIView(context:) + 278 (AddressMapKit.swift:27)
17 app-name 0x10b443299 protocol witness for UIViewRepresentable.makeUIView(context:) in conformance AddressMapKit + 73
let camera: GMSCameraPosition
有正确的位置,输入纬度和经度的静态有效数据并检查,如果现在可以工作AppDelegate
中正确初始化它。mapView.isMyLocationEnabled = true
尝试访问设备的位置。确保您已在 Info.plist 文件中请求并被授予位置权限(NSLocationWhenInUseUsageDescription
用于前台访问)。