rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

BW::Location no longer accessing CLLocation properly in iOS9.1 #480

Open YoDK opened 8 years ago

YoDK commented 8 years ago

Since updating to iOS 9.1 BW::Location seems to no longer return a valid CLLocation (:error=>3).

I can confirm (in 9.1) that BW::Location.enabled? returns true and BW::Location.authorized? also returns true.

Also confirmed that the same code in iPhoneSImulator8.4 returns proper CLLocation

soyoh commented 8 years ago

Hi, any workaround on this?? i'm having the same problem here. in my case in fails on BW::Location.authorized? and asking for permission...

YoDK commented 8 years ago

@soyoh did you include:

  app.frameworks += ['CoreData', 'CoreLocation']
  app.info_plist['NSLocationWhenInUseUsageDescription'] = 'Description.'
  app.info_plist['NSLocationAlwaysUsageDescription'] = 'Description.'

in your apps Motion::Project::App.setup config ?

YoDK commented 8 years ago

FYI: Here' a SO post that can help you install the iOS 8.4 Simulator for Xcode 7.1 (last known working config for BW::Location) - http://stackoverflow.com/questions/33377837/error-sdk-iphonesimulator9-0-cannot-be-located

markrickert commented 8 years ago

The app.frameworks line shouldn't be required here. Bubblewrap automatically includes CoreLocation for you, and CoreLocation doesn't require CoreData as far as I know.

soyoh commented 8 years ago

Hi Guys, Thanks, i managed to see the permissions alert (it was because i missed "NSLocationAlwaysUsageDescription"), but now my app crashes when using "Location::get_once""

this is the error:

2015-11-07 00:35:14.348 app[89887:5025324] functions.rb:15:in `block in get_location_and_users': wrong number of arguments (0 for 1) (ArgumentError)
    from functions.rb:15:in `locationManager:didUpdateLocations:'
2015-11-07 00:35:14.361 app[89887:5025324] expected Proc with 1 arguments (got 0) (ArgumentError)

and this is the code i'm using:

BW::Location.get_once(desired_accuracy: :three_kilometers) do |result|
      mp.result
      if result.is_a?(CLLocation)
        mp result.coordinate.latitude
        mp result.coordinate.longitude
      else
        mp "ERROR: #{result[:error]}"
      end
    end

well, i'm using the simulator, i suppouse that is because of this, and it doesnt provide a location, do you know how can i "fake" it??

any hint? thank you!!

YoDK commented 8 years ago

I'm not sure about the BW error. But you can set the GPS location of the Simulator by going to Debug > Location > Custom Location

Then I use Google Maps to give me the longitude and latitude of a location I'm interested in.

markrickert commented 8 years ago

The sun has always had an issue where it return an error every once in a while. Try turning off the location in the sim and then reactivating it and trying again

OMG... Yes I did just suggest "have you tried turning it off and back on again?" Lol

soyoh commented 8 years ago

haha, i already tried that @markrickert i tried turning off location, removing permissions, and removing app to ask permissions again... the same error happens ios SDK 9.1 and deployment_target 8.4 or 9.0

YoDK commented 8 years ago

Found a workaround that works for iOS9.1 here: http://stackoverflow.com/questions/26675412/how-do-i-get-the-coordinates-of-the-ios-device-using-rubymotion

soyoh commented 8 years ago

Thanks @YoDK ! i've deicded to go this way for now, until BW plays better with ios 9