WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

HOW can I change my location in an iOS app for testing, need a button for testers to change their location in app.

Forums > iOS

I have been looking into core location and cclocationmanager, is there a way to add a button in my app so that our testers change their location? They need to fake their location to start orders and jobs? is there a way to create a CLLocationCoordinate2D(lat, long) and pass it to the core location so the device will think its there? In the simulator, YOU HAVE TO or your at apple, i can change location with features>location>custom location and enter lat and long. This is great but i need my testers to be able to do something similar through the app. If anyone can point to a solution would be grateful.

Thanks for any help or info on how to do this, newish iOS dev

   

You could mess around in the delegate methods with the coordinates but my guess is everytime the location updates your coordinates are overwritten. I don't think this is worth the hassle just for testing.

Is it possible you provide some example locations for testing your testers can choose from? Or do you have to map a route?

   

ya there is an initial geofence, then tracks route, but i can get by if i can just have them switch to fake location for start of job, then switch location and finish job.

   

Then for the sake of testing create example locations and skip location tracking completely and create a pool of locations. So when they start a random location from the pool is chosen and also when they finish.

   

Hacking with Swift is sponsored by Emerge

SPONSORED Why are Swift reference types bad for app startup time, and what’s the performance cost of protocol conformances? That’s just a couple of the topics you can learn about on the Emerge blog — written by the app performance experts behind Emerge’s advanced app optimization and monitoring tools, based on their experience of working at companies like Apple, Airbnb, Snap, and Spotify.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.