xcrun simctl openurl booted '<url>' from Terminal to push any URL into the running simulator, exactly like adb does on Android. If more than one simulator is booted, replace booted with the device UDID from xcrun simctl list devices booted.Why this happens
The iOS Simulator has no adb. There is no console you attach to and no am start equivalent inside the simulator process. Everything you script against the simulator goes through simctl, a command-line tool that ships with Xcode and talks to CoreSimulator directly.
That is actually good news: simctl can open URLs, launch apps with arguments, install builds, and stream logs. Deep linking is just one subcommand. The confusion comes from people looking for a setting inside the Simulator app — there isn’t one. The URL has to be handed to the simulator from outside.
One thing to keep straight before you start: a custom URL scheme (myapp://) always routes to your app if the scheme is declared in Info.plist. A universal link (https://yourdomain.com/...) only routes to your app when the Associated Domains entitlement is present, the app is installed, and iOS has associated that domain with it. If the association isn’t in place, the link opens in Safari — which is correct fallback behaviour, not a bug.
How to fix it
1. Use xcrun simctl openurl booted
This is the direct answer. With a simulator already running:
xcrun simctl openurl booted 'myapp://profile/42'
Quote the URL. Unquoted &, ? and # characters get eaten by the shell before simctl ever sees them.
Check which devices are booted first if you are unsure:
xcrun simctl list devices booted
If more than one simulator is running, booted is ambiguous — pass the UDID instead so you know which device receives the link:
xcrun simctl openurl 8A1B2C3D-4E5F-6789-ABCD-EF0123456789 'myapp://profile/42'
If no simulator is running, boot one and wait for it to finish starting before sending the URL:
xcrun simctl boot 'iPhone 17 Pro'
open -a Simulator
xcrun simctl openurl booted 'myapp://profile/42'
simctl needs the Xcode command line tools. If the command is not found, check with xcode-select -p and point it at your Xcode with sudo xcode-select -s /Applications/Xcode.app.
2. Confirm the URL scheme is actually declared
If simctl runs without error but nothing happens, the scheme is usually missing from the built app. Add it to the target’s Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.example.myapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>
In Xcode you can also add it through the target’s Info tab → URL Types. Rebuild and reinstall after changing it; the simulator runs the installed bundle, not your source.
Then make sure the app handles the URL. In SwiftUI, .onOpenURL on the root view is enough:
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
guard url.scheme == "myapp", url.host == "profile" else { return }
let id = url.lastPathComponent // "42"
// route to the profile screen with `id`
}
}
}
}
In UIKit, use the scene delegate for scene-based apps:
func scene(_ scene: UIScene, openURLContexts contexts: Set<UIOpenURLContext>) {
for context in contexts where context.url.scheme == "myapp" {
// route using context.url
}
}
Older app-delegate lifecycle apps use application(_:open:options:) instead.
3. Test the tap path with Safari or Contacts
simctl openurl proves your routing code works, but it bypasses the tap. When you need to verify the full user path, use the Simulator’s own UI:
- Safari — type the URL into the address bar and press Go. This is the closest thing to a real link tap and is the quickest way to check whether a universal link falls back to the web.
- Contacts — open Contacts, pick a seeded contact such as John Appleseed, tap Edit, scroll down, tap add url, and paste your link. Save, then tap the link in the contact card. Give each URL a custom label (
profile,promo,reset) so you can tell them apart. Note that resetting the simulator wipes Contacts back to defaults and you lose them.
You can also drag files from Finder onto the Simulator window to hand them to a Share Extension, which is handy for testing document-based deep links.
4. Wrap it in a shell function
You will type this dozens of times a day, so shorten it:
openlink() { xcrun simctl openurl booted "$1"; }
Add that to ~/.zshrc, then openlink 'myapp://profile/42'. If you want it inside Xcode, add a Run Script build phase that calls xcrun simctl openurl booted "$SCHEME_URL" — but keep it out of release configurations, since it will fail on a machine with no booted simulator.
Related commands worth knowing while you are in there:
xcrun simctl launch booted com.example.myapp
xcrun simctl terminate booted com.example.myapp
xcrun simctl help openurl
How to prevent it
- Keep a list of every URL your app accepts in one place (a constants file or a test fixture), and drive both your routing code and your test scripts from it.
- Test cold and warm launches separately:
simctl terminatethe app first, then send the URL, because a cold launch goes through a different code path than a backgrounded app. - Percent-encode query values before building the URL —
simctlwill happily pass a malformed URL straight through to your handler. - Rebuild and reinstall after editing
Info.plist; a stale installed bundle is the most common reason a new scheme “doesn’t work”. - For universal links, verify the association rather than assuming it: if the link opens Safari in the simulator, the entitlement or the domain association is missing.
FAQ
Does xcrun simctl openurl work on a physical device?
No. simctl only talks to the Simulator. On a real device, tap the link, use a Notes or Messages draft, or send it to yourself — there is no supported command-line equivalent.
Why does my universal link open Safari in the Simulator instead of my app?
Because iOS did not associate that domain with your installed app. Check that the Associated Domains entitlement is on the target you installed, that the domain serves a valid apple-app-site-assistance file, and that the app was reinstalled after the entitlement changed.
Can I pass launch arguments instead of a URL?
Yes — xcrun simctl launch booted com.example.myapp -MyFlag YES passes arguments to the process, which is useful for test hooks. It is not a substitute for deep linking though, since it does not exercise your URL routing code.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
