Search code examples
iosrubymotion

How to test ios version without bubblewrap


I'd like to open maps on ios6 by usine MKMapItem but I'd also like fallback using google maps for older ios versions...

I have no Idea to do this on rubymtion without BubbleWrap cause Device.ios_version return me an error

I want to this this on iOS6 :

address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
mapItem = MKMapItem.alloc.initWithPlacemark(place)
mapItem.name = "#{@party.name}"
options = ({
   MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
})
mapItem.openInMapsWithLaunchOptions(options)

And this on older versions :

url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
App::open_url(url)

Thanks for your help


And then when I do the correct test : When I do the test and I run it on IOS 5.1 I have this error

dyld: Symbol not found: _MKLaunchOptionsDirectionsModeDriving

This is my code :

if Utils.older_than_ios6?
  url = "http://maps.google.com/maps?saddr=#{@party.place.location[1]},#{@party.place.location[0]}&daddr=#{@party.place.location[1]},#{@party.place.location[0]}"
  App::open_url(url)
else
  address_dictionnary = ({kABPersonAddressStreetKey: @party.place.street, kABPersonAddressCityKey: @party.place.city,kABPersonAddressZIPKey: @party.place.postal_code})
  place = MKPlacemark.alloc.initWithCoordinate(@coords, addressDictionary: address_dictionnary)
  mapItem = MKMapItem.alloc.initWithPlacemark(place)
  mapItem.name = "#{@party.name}"
  options = ({
     MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
  })
  mapItem.openInMapsWithLaunchOptions(options)
end

Solution

  • By checking the source for Device.ios_version, you can see that it returns UIDevice.currentDevice.systemVersion. So this should do the trick !