簡體   English   中英

在xcode 7.3.1中使用未解析的標識符“GMSPlacesClient”

[英]Use of unresolved identifier 'GMSPlacesClient' in xcode 7.3.1

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

我用這種方法在谷歌地圖中搜索地址。 但是找到了Use of unresolved identifier 'GMSPlacesClient'錯誤。 我怎么能解決這個問題?

如果使用cocoapod,則需要添加pod'GooglePlaces'。 並導入GooglePlaces。

當您的新類與另一個目標具有不同的目標時,可能會發生Use of unresolved identifier 'GMSPlacesClient'錯誤。 在這個帖子中聲明它可能有一個測試目標而另一個沒有。 對於這種情況,您必須在測試目標中包含所有類,或者不包括任何類。

博客還提供了錯誤的可能解決方案,“使用未解析的標識符”。 將您班級的訪問控制權更改為公開。 此外,還要標記您打算使用public測試的任何方法。 還要嘗試將您希望能夠編寫單元測試的類添加到測試目標中。

您還可以查看此相關的SO問題 希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM