7
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?

Mistalis
  • 17,793
  • 13
  • 73
  • 97
Shahbaz Akram
  • 1,598
  • 3
  • 28
  • 45

2 Answers2

14

If use cocoapod, you need add pod 'GooglePlaces'. And import GooglePlaces.

Valeriy
  • 723
  • 6
  • 17
3

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!

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59