For developers

How to simulate location on an iPhone with Xcode

Updated · By the Geovo team

Xcode can simulate a location on a real iPhone or the Simulator while your app runs from Xcode, using a preset city or a GPX file, and it can set locations in tests. It's free and precise. It's also tied to a Mac, an app project and a debugging session, which is where a tool like Geovo helps.

How does Xcode simulate location?

Xcode sends a simulated position to Core Location while your app runs from Xcode, so CLLocationManager returns that position instead of real GPS. You set it in the scheme's Run options before launch, change it from the debug bar while running, or configure it in a test plan. All of this is described in Apple's Xcode documentation.

On a physical iPhone, Developer Mode must be on for Xcode to run your app (Apple: Enabling Developer Mode).

How to set a default location in the scheme

Setting a default location in the scheme makes every run start at the same place, which is ideal for repeatable debugging. Apple's steps: Edit Scheme, choose the Run action, open Options, enable Allow Location Simulation under Core Location, then pick a city or a GPX file as the Default Location.

  1. In the toolbar's scheme menu choose Edit Scheme.
  2. Select Run, then Options.
  3. Check Allow Location Simulation under Core Location.
  4. Pick a Default Location: None, a preset city, or Add GPX File to Project.

Source: Simulate a runtime location in the scheme editor.

How to change location while debugging

While your app is running from Xcode, you can switch to another simulated location without relaunching. In the debug area, click the Simulate Location button and pick a preset city or a GPX file from your project. Choose "Don't Simulate Location" to return to the device's real location.

Source: Simulate a location in the debugger.

How do GPX files work in Xcode?

Xcode plays GPX files made of waypoints: each wpt element is a point, visited in order. Apple's Xcode Help says route (rte) and track (trk) tags are not supported, so a GPX exported from a fitness or mapping app may need converting to waypoints first. Timestamps on waypoints control pacing.

A minimal file looks like a gpx root element containing one or more wpt elements, each with lat and lon attributes and an optional time. Keep test routes in your repo so the whole team replays the same path.

How to simulate location in tests

For automated tests, Apple recommends controlling location inputs so results don't depend on where the test machine is. You can set a simulated location or GPX journey in a test plan's configuration, construct CLLocation values directly in unit tests, and set XCUIDevice.shared.location in UI automation tests.

  • Test plan: Product › Test Plan › Edit Test Plan › Configuration › Simulated Location. Apple notes this applies only to code in the test bundle; UI tests run your app as a separate process.
  • UI tests: set XCUIDevice.shared.location to an XCUILocation built from a CLLocation.
  • Unit tests: pass known CLLocationCoordinate2D values to the code under test.

Source: Simulating location in tests.

Can apps tell the location is simulated?

Yes, they can ask. Since iOS 15, Core Location attaches source information to each location, including whether it was simulated by software. Apple gives the example of an app rejecting simulated locations when it isn't being debugged or tested, so test both paths if your app reads it.

See CLLocationSourceInformation in Apple's documentation.

Xcode location simulation vs Geovo
XcodeGeovo
CostFreeFree 30 min/day; Pro from $5.99/week
ComputerMac onlyMac or Windows 10/11
Needs an app projectYesNo
Which buildsYour app while it runs from Xcode, and testsThe whole iPhone: any app, including TestFlight and App Store builds
Pick a locationPreset cities, GPX filesMap and search (Apple Maps on Mac), favorites, recents
MovementGPX waypointsRoutes along roads at walk/cycle/drive speed, joystick, GPX import/export
UnpluggedNoYes, via the iPhone app and LocalDevVPN (renew every 7 days)
AutomationTest plans, XCUIDevice in UI testsSchedules; no test-framework API
Xcode behaviour from Apple's Xcode Help and developer documentation (links above).

What are Xcode's limits for location testing?

Xcode's location simulation is built around debugging your own app on a Mac. It needs the project, a run from Xcode and a Mac nearby. It has no map to click, reads only GPX waypoints, and isn't meant for QA or product teammates on Windows, for release builds, or for testing away from the desk.

When does a tool like Geovo help?

Geovo helps when location testing moves beyond the debugger: QA on Windows, TestFlight or App Store builds, long routes at realistic speeds, or field-style tests with the phone unplugged. It sets the location for the whole iPhone without Xcode or a project, and anyone on the team can use it.

  • No Xcode or project: product, QA and support can reproduce location bugs.
  • Windows: the same features on Windows 10/11.
  • Routes and joystick: play a road route at walking, cycling or driving speed, or steer.
  • GPX: import and export; for files to play in both, use waypoints.
  • Untethered: the iPhone app works on Wi-Fi, cellular and in Airplane Mode.
  • Privacy: coordinates never leave your devices.

More workflows (geofences, tracking, regional content) are in testing location features on a real iPhone. To get started, download Geovo or check pricing: a weekly plan ($5.99) covers a single release cycle.

Who is each best for?

  • Xcode: developers debugging and unit or UI testing their own app on a Mac.
  • Geovo: QA, product and support teams, Windows users, release and TestFlight builds, long or repeatable routes, and testing with the phone unplugged.

Use it responsibly

Geovo is for adults and for lawful use only: testing apps and websites, keeping your real position private from an app that doesn't need it, demos, travel planning and teaching how location services work. Don't use any location tool to mislead people or to break the terms of an app or service you've agreed to.

Frequently asked questions

How do I simulate location on a real iPhone with Xcode?
Turn on Developer Mode, run your app from Xcode, then pick a location with the Simulate Location button in the debug bar, or set a Default Location in the scheme's Run options.
Why won't my GPX route play in Xcode?
Apple's Xcode Help says only GPX waypoints (wpt) are supported; route (rte) and track (trk) tags aren't. Convert the file to waypoints.
Can I simulate location on iPhone without Xcode?
Yes. Desktop tools like Geovo use the same Apple developer location service without Xcode or an app project, on Mac or Windows, and Geovo's iPhone app works unplugged.
Does Xcode's simulated location affect TestFlight builds?
Xcode simulates location for your app while it runs from Xcode and in tests. To test TestFlight or App Store builds, use a tool that sets the location for the whole iPhone, such as Geovo.
Can I use the same GPX file in Xcode and Geovo?
Geovo imports and exports GPX. Xcode reads waypoints only, so use waypoint-based files if you want one file to work in both.
Can my app detect simulated locations?
Yes. Since iOS 15, CLLocationSourceInformation tells your app whether a location was simulated by software. Test both paths if you rely on it.

Try Geovo free

30 minutes every day, every feature. Mac and Windows.