Exception:Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:…] prior to use

前端 未结 10 1859
挽巷
挽巷 2021-01-04 12:44

I am trying to implement Google Maps SDK into my project using Swift 2.0. I follow this but when running this, my app is getting the following error:

2015-08         


        
10条回答
  •  清酒与你
    2021-01-04 13:39

    I just had the same problem. I created a GMSMapView object and it was initialized before maybe the api key could be read. So I moved it inside the viewDidLoad method and problem solved.

    Before :

    class ViewController: ..... {
    
    let mapView = GMSMapView()
    

    After :

    class ViewController: ..... {
    
    var mapView : GMSMapView?
    
    override viewDidLoad(){
        mapView = GMSMapView()
    

提交回复
热议问题