在xcode 7.3.1中使用未parsing的标识符'GMSPlacesClient'

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) } } 

我用这个方法search谷歌地图的地址。 但findUse of unresolved identifier 'GMSPlacesClient'错误。 我怎么解决这个问题?

当您的新类别与另一个类别具有不同的目标时,可能会Use of unresolved identifier 'GMSPlacesClient'错误。 在这个线程中提到它可能有一个testing目标,另一个则没有。 对于这种情况,您必须将所有类都包含在testing目标中,或者不包含任何类。

这个博客还为错误提供了可能的解决scheme,“使用未parsing的标识符”。 将您class级的访问控制更改为公开。 此外,还可以用公共方法标记您想要testing的任何方法。 也可以尝试添加您希望能够为testing目标编写unit testing的类。

你也可以检查这个相关的SO问题 。 希望这可以帮助!

如果使用cocoapod,则需要添加pod“GooglePlaces”。 并导入GooglePlaces。