Failed to load optimized model at path error with

2019-04-29 05:22发布

问题:

I am trying to use the Google Places API autocomplete feature in my code.

    import UIKit
import GoogleMaps

class ViewController: UIViewController, GMSMapViewDelegate {

    var placesClient: GMSPlacesClient?

    override func viewDidLoad() {
        super.viewDidLoad()

        placesClient = GMSPlacesClient()

        let filter = GMSAutocompleteFilter()
        filter.type = GMSPlacesAutocompleteTypeFilter.City
        placesClient?.autocompleteQuery("Pizza", bounds: nil, filter: filter, callback: { (results, error: NSError?) -> Void in
            if let error = error {
                print("Autocomplete error \(error)")
            }

            for result in results! {
                if let result = result as? GMSAutocompletePrediction {
                    print("Result \(result.attributedFullText) with placeID \(result.placeID)")
                }
            }
        })

    }
}

When I run it I am getting this error: CoreData: Failed to load optimized model at path '/var/mobile/Containers/Bundle/Application/ Any ideas?

回答1:

Add -ObjC to "Other Linker Flags"

(Build Settings -> Linking -> Other Linker Flags). 

This solved it for me.

After I added this flag I received some errors regarding missing symbols (such as _CBAdvertisementDataManufacturerDataKey).

I added the Accelerate and CoreBluetooth frameworks in *Build Phases -> Link Binary With Libraries*.



回答2:

This issue is fixed in the new update of Google maps https://developers.google.com/maps/documentation/ios-sdk/releases?hl=en Check this Link and update your local repositories