Why this happens
Simulator supplies a simulated location to apps that use Core Location. That location may not be the place you expect for your test, and it is not necessarily the physical location of your Mac. You can change it without changing your app’s location code.
A wrong or missing location can also come from the app rather than the simulation setting. For example, the app might not have location permission, might still be displaying a previously received coordinate, or might not have requested a new location. Check the simulation setting first, then inspect the values and errors your app receives.
How to fix it
1. Set a custom location in Simulator
Use a custom location when you need to test one coordinate quickly. This is the most direct fix and does not require a project file.
- Run your app from Xcode on an iPhone Simulator.
- Bring the Simulator app to the foreground. Its menus are separate from Xcode’s menus.
- Find the Location submenu in Simulator’s menu bar. Depending on the Simulator version, it may be under Features or Debug.
- Choose Custom Location.
- Enter the latitude and longitude in decimal degrees and confirm the selection.
- Return to your app and request or observe a new location update.
For example, you can enter latitude 53.936166 and longitude 27.565370 to match the GPX example below. Enter latitude first and longitude second; they represent different axes, and swapping them can put the simulated device in an unintended place.
If your app still displays an old value, check whether it is showing a cached coordinate or whether its location manager is actively requesting updates. Selecting a location in Simulator does not by itself guarantee that your interface refreshes.
2. Add a GPX file for a repeatable location
A GPX file is useful when you want to keep a named test coordinate with your project. Unlike typing the coordinate each time, a file gives you a reusable input that other developers can select too.
Create a plain-text file named MyOffice.gpx with this content:
<?xml version="1.0"?>
<gpx version="1.0" creator="MyApp">
<wpt lat="53.936166" lon="27.565370">
<name>MyOffice</name>
</wpt>
</gpx>
Then:
- Run the project in Simulator.
- In Xcode, find the simulated location controls in the debug area or the Debug menu.
- Choose Add GPX File to Project… and select
MyOffice.gpx. - Select the added location from Xcode’s simulated location controls.
- Trigger a new location request in your app and check the resulting coordinate.
The file above contains one waypoint, so use it to test a fixed location, not movement. You can replace the lat and lon values and give the waypoint a name that describes the scenario. Keep the .gpx extension and make sure the editor saves plain text rather than rich text.
If the file does not appear as an option, confirm that it was added to the project and that you are looking at Xcode’s simulated location controls while debugging the intended app. Menu placement can differ between Xcode versions.
3. Use a simulated route for movement
A fixed coordinate is not enough to test behavior that depends on the device moving. Simulator’s Location submenu also provides predefined movement simulations, such as a city walk or run and a freeway drive, depending on the available options in your version.
- Start the app in Simulator.
- Open Simulator’s Location submenu.
- Select an available movement simulation.
- Watch the coordinates delivered to the app over time.
Use this for checks such as whether a map follows location updates or whether your interface responds to a changing coordinate. A route is a simulation, so do not assume its starting point is near the custom location you entered earlier.
When you are done testing movement, switch back to a custom or named fixed location if the next test requires a stable coordinate.
4. Check permission and incoming location values
If changing the simulated location has no visible effect, verify that the app is allowed to receive location data and that it handles updates. Simulator location settings do not replace Core Location authorization.
Check that:
- Your app includes the appropriate location usage description in its configuration. For a when-in-use request, that is
NSLocationWhenInUseUsageDescription. - The app requests the authorization appropriate to its use of location, and the user has granted it in Simulator.
- Your location manager requests a location or starts updates at the point you expect.
- Your delegate handles both delivered locations and failures.
- The UI reads the new coordinate rather than continuing to display a saved or cached value.
If you already use a CLLocationManagerDelegate, add a temporary log inside your existing update callback:
print("Location:", location.coordinate.latitude,
location.coordinate.longitude)
Here, location should be a CLLocation received by your delegate. Compare the printed values with the coordinates selected in Simulator. If the log shows the expected coordinate but the screen does not, investigate how your app passes location updates to its UI. If no update arrives, inspect the delegate’s error callback and the app’s authorization state.
Changing the simulated location and changing permission are separate operations. If permission was denied earlier, review the app’s location permission in the simulated device’s Settings before trying again.
How to prevent it
- Name GPX files after the scenarios they represent, so test coordinates are easy to identify.
- Record whether each test needs a fixed location or a moving simulation.
- Log received coordinates and location errors while diagnosing a mismatch.
- Check authorization and request a fresh update before treating an old displayed value as the current location.
- Confirm which simulated device and app are running before changing location settings.
FAQ
Does Simulator automatically use my Mac’s location?
Do not rely on Simulator matching your Mac’s physical location. Select an explicit custom location or GPX test location when your result depends on a known coordinate.
Can I test location without adding a GPX file?
Yes. Choose Custom Location from Simulator’s Location submenu and enter a latitude and longitude. GPX is helpful when you want to reuse a named coordinate.
Why does my app still show the previous location?
It may be displaying a cached value, or it may not have received a new update after you changed the simulation. Check permission, the location request, delegate errors, and the coordinates received by your app before debugging the UI.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
