CLLocationMiddleManager lets you spoof location information on devices just like the Simulator does.
Simply replace
let locationManager = CLLocationManager()
with
let locationManager = CLLocationMiddleManager(file: "my_gpx_route")
and it should all just workTM.
CLLocationMiddleManager is Carthage-compatible.
github "Shrugs/CLLocationMiddleManager" >= 1.0
Ignore the warnings about a directory, not sure what's up with those.
CLLocationMiddleManager works by interpreting a gpx
file that's included in your app's bundle.
- Go to Google Maps and draw out a route by clicking on the map.
- Copy the url from Google Maps
- Go to Coruscant Consulting's website and paste in your Google Maps link
- Download the resulting GPX file
- Open that file up in your favorite text editor (or Xcode)
- Add
<time>
keys to eachwpt
.- For example, a waypoint should look something like
<wpt lat="42.357542" lon="-83.059571"><time>2015-09-13T14:19:35Z</time></wpt>
- The time is in the format
yyyy-MM-ddTHH:mm:ssZ
- For example,
2015-09-13T14:19:35Z
is a valid time
- For example, a waypoint should look something like
- Import that GPX file into Xcode by dragging it into your Project pane and making sure to Copy files if needed
- Add something similar to the following code in your app.
let demoMode = true // this can be a Compiler Flag or anything you want
let locationManager = demoMode ? CLLocationMiddleManager(file: "my_gpx_route") : CLLocationManager()
And tada, you're spoofing location on device. Woo!