lsapan / pgoapi-swift

A Pokemon GO API library for Swift
MIT License
97 stars 29 forks source link

Compiler error from "PGoUtils.swift" - OSX only [bug] #52

Closed subzerofun closed 8 years ago

subzerofun commented 8 years ago

Hey thanks for addition of OSX support to the pod! (i was the one asking for it in Issue #42)

I tried to compile my project with the updated pod, but in the File PGoUtils.swift, at line 3:

import AddressBookUI

an iOS only Framework gets imported. Since there is no equivalent Framework for OSX/macOS the function ABCreateStringWithAddressDictionary at line 45 isn´t defined:

let location = CLLocation(latitude: latitude, longitude: longitude)
CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
    if placemarks?.count > 0 {
        let addressDictionary = placemarks![0]
       // right there:
        let address = ABCreateStringWithAddressDictionary(addressDictionary.addressDictionary!, false)
        completionHandler(location: address.stringByReplacingOccurrencesOfString("\n", withString: ", "))
    }
})

I tried to replace the framework, but i could just find an old Obj-C library that doesn´t provide the function needed.

So for now i have just uncommented the block with ABCreateStringWithAddressDictionary and everything compiles fine. But since the function CLGeocoder is also needed right below in

 public func reverseGeocode(...) {
        (...)
        let geocoder = CLGeocoder()
        (...)
}

could that render the API unusable for me? Since i had to uncomment everything that happens in func CLGeocoder... and then that function is referenced in reverseGeocode and doesn´t compute anything...

Is this function essential for map queries? If it is – please help me to find a solution for OSX.

PokemonGoSucks commented 8 years ago

This is non-essential code and can be commented out. I will go ahead and remove this from the utils and find an alternative.

The entire utils file is non-essential and can be removed if you need. It's to make it easier to build a map/bot based off the api.

Should be solved in c742465f29dc1934c00c936e13ce8d80f0e7dcc4

subzerofun commented 8 years ago

My aim is to write a little Swift App that uses the OSX MapKit Framework to display the positions of multiple users (and give live feedback about found pokemon) – a simple map scanner basically (a reduced version of the PokemonGo-Map project).

Won´t i run into problems with getting map coordinates if i uncomment this line?

PokemonGoSucks commented 8 years ago

Nope. You can delete the entire file if you need to. It's just extra stuff to help build bots/scrappers.

I also removed it in the last commit so it should work in OSX now.

subzerofun commented 8 years ago

OK, thanks. Also thanks for the rewritten PGoUtils.swift!