iOS Question Manually set location in Simulator to trigger geofences?

Sandman

Expert
Licensed User
I'm working with geofences, and it's getting tiresome to code something, go to the car and drive around for a while to see if it worked, go back and code some more, go to the car, etc.

So I'm thinking the Apple Simulator might be something for me to use most of the time and only rarely go to the car. I've never used the simulator, and currently I don't even have a mac to test it on. Before actually buying a mac, I'm wondering if somebody knows if it's actually possible to manually set the location for the simulated device?

I've searched the Interwebs, but come up empty on this specific detail. I've seen a screenshot of the menu in XCode and I couldn't see anything about location there, so that wasn't very promising.

You that have access to the simulator, could you please check if it's possible to set the location? And if it's not too much trouble, perhaps attach a screenshot of the window where one sets it?
 

JordiCP

Expert
Licensed User
Longtime User
Some months ago I started exploring the iOS background location world, since I needed it for one of my apps. In my case I only needed the significant location changes feature, which only fires under some circumstances and is not deterministic at all (relies more on some sort of triangulation between cell tower changes and wifi, than on frequent GPS updates), but was more than enough for my purpose --> making sure that the app would wake up at some moment even if it had been swipe-killed.

At the end, I never used the simulator for it (also tested it with my car and/or bike, which was funny), but during the previous 'investigation' process I saved some links which I thought could be useful in the future.

THIS article seems to explain it quite well, with XCode screenshots of how to set it. Seems that the way to go is with GPX files, also explained in the post.
 
Upvote 0

Sandman

Expert
Licensed User
Thanks! GPX files doesn't seem like a perfect fit for my needs, but I suppose they're better than going to the car over and over. :)

So what you're saying is that we can use the hosted builder, use the "Download Simulator Release App" and then use that build in the simulator to do the GPX thing. Correct?
 
Upvote 0

MikeH

Well-Known Member
Licensed User
Longtime User
Yes, it is entirely possible to set a location in the iOS simulator:


1645963280762.png


From there you can input GPS coordinates:

1645963519689.png
 
Upvote 0

Sandman

Expert
Licensed User
Yes, it is entirely possible to set a location in the iOS simulator:
Yeah, the article @JordiCP linked to shows this:
1645963397019.png

That's nice, I suppose, but I was really hoping for a zoomable map where I could just click or perhaps slowly drag (while mouse is pressed) to simulate travelling.
 
Upvote 0

MikeH

Well-Known Member
Licensed User
Longtime User
Yeah, the article @JordiCP linked to shows this:
View attachment 126156
That's nice, I suppose, but I was really hoping for a zoomable map where I could just click or perhaps slowly drag (while mouse is pressed) to simulate travelling.
Those other options simulates a journey, so to test geofences using this method, you'd have to place test points in your code along the routes
 
Upvote 0

Sandman

Expert
Licensed User
Those other options simulates a journey, so to test geofences using this method, you'd have to place test points in your code along the routes
That's not a bad idea actually. According to this article, it seems they're all around Apple HQ, but I couldn't find any exact routes online. I suppose it's bit of trial and error and simulating the route while staring at the Apple Maps app to see locations swoosh by.
 
Upvote 0

Sandman

Expert
Licensed User
This outdated document is the best source I've found for the routes:
  • City Bicycle Ride. Simulates a bike ride in Cupertino, CA. This item simulates the device moving on a predefined route.
  • City Run. Simulates a run in Cupertino, CA. This item simulates the device moving on a predefined route.
  • Freeway Drive. Simulates a drive through Cupertino, CA. This item simulates the device moving on a predefined route.
 
Upvote 0

MikeH

Well-Known Member
Licensed User
Longtime User
Yes, I've used it in the past for GPS based apps and found it very useful. You can watch your location travel around on a map, just as you say.
 
Upvote 0

Sandman

Expert
Licensed User
@MikeH: Do you use the hosted builder for this? And if so, is it simple to use the build from it in the simulator, or is it a somewhat painful multi-step process each time?
 
Upvote 0

MikeH

Well-Known Member
Licensed User
Longtime User
Last edited:
Upvote 0
Top