我有一个应用程序,其中有一个使用谷歌地图的屏幕,它在模拟器中完美地工作,但当我试图在ios 10.3应用程序运行的真实设备(iphone 5s)中运行应用程序但是当我去的时候它崩溃了任何使用谷歌地图的屏幕
并收到此错误
2017-08-14 00:44:48.425934+0200 MyApp[3603:866147] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-08-14 00:44:48.678827+0200 Carwash[3603:866147] fatal error: unexpectedly found nil while unwrapping an Optional value
这是我的代码:
Appdelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("MyApiKey")
return true
}
在视图中映射控制器:
import GoogleMaps
class HomeViewController: UIViewController {
// MARK: - Vars
var locManager = CLLocationManager()
var currentLocation: CLLocation!
var coordinates:CLLocationCoordinate2D!
// MARK- Outlets
@IBOutlet weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setUpMap()
}
// MARK: - set up map
func setUpMap()
{
//Location Manager code to fetch current location
self.locManager.delegate = self
self.locManager.startUpdatingLocation()
currentLocation = locManager.location
let camera = GMSCameraPosition.camera(withLatitude:currentLocation.coordinate.latitude,longitude: currentLocation.coordinate.longitude, zoom: 14)
let marker = GMSMarker(position : CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude))
marker.map = mapView
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
mapView.delegate = self
self.mapView.camera = camera
self.coordinates = CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
}
}
// Mark: -CLLocationManagerDelegate
extension HomeViewController: CLLocationManagerDelegate , GMSMapViewDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
locManager.startUpdatingLocation()
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.first {
mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
locManager.stopUpdatingLocation()
}
}
}
任何人都知道什么是错的?