Search code examples
iosxcodeswiftgoogle-places-apixcode6.4

Issue with Google Places Current Place not working in XCode 6.4


I am developing an iOS app with Xcode 6.4, Swift version 1.2.

I am trying to use Google Places API's functionality Current Place in my app, in order to get the list of places close to the user, then display them in a tableView. In order to guess the location, I have created this function that activates every time the text in search bar changes, and populates an array called PossiblePlaces with suggestions that adapt in real time:

func search(searchText: String? = nil){

    self.possiblePlaces = []
    if searchText != nil {
        println("before query")
    placesClient?.currentPlaceWithCallback({ (placeLikelihoods:GMSPlaceLikelihoodList?, error:NSError?) -> Void in

        if error != nil {
            println("error")

        }
        if error == nil {
            println("query ended")

            for likelihood in placeLikelihoods!.likelihoods {
                println(likelihood)
                let place = likelihood.name
                let id = likelihood.identifier
                println(id)
                println(place)
                var suggestion = postedPlace(name: place, id: id)
                self.possiblePlaces.append(suggestion)

            }

           self.autocompleteTableView.reloadData()
        }
    })
    }
    }

As far as I can tell, the function launches correctly: I get the "before query" message every time the text changes. However, I get neither "error", nor "query ended", seemingly meaning that the query never launches. I don't know why: the API key is correct, I even get a message on my Google Maps SDK version in the console when the GMSPlacesClient is initialized (in the ViewDidLoad), so I assume the integration works.

I appreciate any input!

Thanks


Solution

  • OK for those who might run into the same issue, it seems that the problem lies with the iOS version that the simulator assumes the simulated device to have. Simply put, this issue does not appear on iPhone 6 simulator, probably because Xcode assumes that the iOS on the device is at least iOS 7.0.