func searchBar(searchBar: UISearchBar,
textDidChange searchText: String){
let placesClient = GMSPlacesClient()
placesClient.autocompleteQuery(searchText, bounds: nil, filter: nil) { (results, error:NSError?) -> Void in
self.resultsArray.removeAll()
if results == nil {
return
}
for result in results!{
if let result = result as? GMSAutocompletePrediction{
self.resultsArray.append(result.attributedFullText.string)
}
}
self.searchResultController.reloadDataWithArray(self.resultsArray)
}
}
I used this method to searching address in google map. But Use of unresolved identifier 'GMSPlacesClient'
error found. How could I resolve this?
Try reducing the "unresolved" source file down to the bare minimum, cleaning and building. Once it builds successfully add all the complexity back to your class. This has made it go away for me when re-starting Xcode did not work.
'Use of Unresolved Identifier' in Swift my also happen when you forgot to import a library. For example I have the error: Show activity on this post. Sometimes the compiler gets confused about the syntax in your class. This happens a lot if you paste in source from somewhere else.
This happens a lot if you paste in source from somewhere else. Try reducing the "unresolved" source file down to the bare minimum, cleaning and building. Once it builds successfully add all the complexity back to your class. This has made it go away for me when re-starting Xcode did not work.
If use cocoapod, you need add pod 'GooglePlaces'. And import GooglePlaces.
Use of unresolved identifier 'GMSPlacesClient'
error probably occurs when your new class has a different Target(s) from the other one. It is stated in this thread that it might have a testing target and the other doesn't. For this case, you have to include all of your classes in the testing target or none of them.
This blog also gives possible solution for error, “Use of unresolved identifier”. Change the access control on your class to public. Additionally, mark any methods you intend to test with public also. Try also to add the class(es) you want to be able to write unit tests for to the tests target.
You can also check this related SO question. Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With