
Control location information of iOS simulator from the command line
This page has been translated by machine translation. View original
The other day, I was testing geofence functionality across multiple locations. While manually switching locations from the Debug menu in the iOS simulator, I started to feel the inefficiency of this process after checking more than 10 test points in sequence.
Looking for a more efficient method, I discovered that the xcrun simctl command allows direct control of location information from the command line. When I tried it, it was even more convenient than I had imagined.
This article introduces how to set and change iOS simulator location from the command line.
Test Environment
- macOS 15.7
- Xcode 26.0
- iPhone Air / iOS 26.0
Basic Usage
Step 1: Check the simulator device ID
To set location information, you need to identify the target simulator. You can check the list of available simulators with the following command:
# Display list of available simulators
xcrun simctl list devices
Example output:
== Devices ==
-- iOS 26.0 --
iPhone 17 Pro (4FC327A0-9628-43E7-A8A3-766770D04E31) (Shutdown)
iPhone 17 Pro Max (C3FE4AB6-C359-4690-A1E6-0503D32D4412) (Shutdown)
iPhone Air (0C7FAC3A-A6DC-4D4E-885E-D359A94C0654) (Booted)
Running simulators are marked with "(Booted)". In this case, you can also use the booted keyword instead of the device ID.
Step 2: Set location information
Use the following command to set specific latitude and longitude:
# Basic syntax
xcrun simctl location <device_id> set <latitude>,<longitude>
# Set Tokyo Station coordinates for the currently running simulator
xcrun simctl location booted set 35.6812,139.7671
# Set Osaka Station coordinates for the currently running simulator
xcrun simctl location booted set 34.702331,135.496025
# When specifying a particular device ID
xcrun simctl location 0C7FAC3A-A6DC-4D4E-885E-D359A94C0654 set 35.6812,139.7671
Step 3: Verify the settings
You can verify that the location information has been set correctly by opening the Maps app on the simulator. When you tap the current location icon, the position at the coordinates you set will be displayed.
Resetting Location Information
After completing tests, you can clear location information:
# Clear location information
xcrun simctl location booted clear
Running this command resets the simulator's location setting to "None".
Summary
Using the xcrun simctl location command allows you to easily control iOS simulator location information from the command line.
If you're a developer working on developing or testing location-based features, I encourage you to try this method. It should help improve your development efficiency.


