iOS Simulator
deep linking
Xcode
app development
iOS testing

Pass deep link into iOS Simulator?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Testing deep links in iOS Simulator is straightforward once you use the correct tooling. The standard method is xcrun simctl openurl, which sends a URL to a booted simulator as if the user opened it from another app. This works for custom URL schemes and Universal Links, provided your app configuration is correct. Reliable deep-link testing should cover cold start and warm start behavior, query parameters, and invalid URL handling. Automating these tests saves significant time compared to manual tapping through UI flows.

Core Sections

Boot a simulator and open a URL:

bash
xcrun simctl boot "iPhone 16"
xcrun simctl openurl booted "myapp://product/42?ref=promo"

If multiple simulators are running, target a specific device UDID instead of booted.

Configure app URL scheme correctly

For custom schemes, ensure Info.plist includes CFBundleURLTypes.

xml
1<key>CFBundleURLTypes</key>
2<array>
3  <dict>
4    <key>CFBundleURLSchemes</key>
5    <array>
6      <string>myapp</string>
7    </array>
8  </dict>
9</array>

Then handle URLs in scene or app delegate methods.

swift
1func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
2    guard let url = URLContexts.first?.url else { return }
3    router.handle(url)
4}

For Universal Links, verify associated domains entitlement and hosted apple-app-site-association file. On simulator, link behavior can depend on Safari context and domain trust state.

swift
1func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
2    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
3          let url = userActivity.webpageURL else { return }
4    router.handle(url)
5}

Add repeatable test scripts

Automate frequent deep-link scenarios with shell scripts.

bash
1#!/usr/bin/env bash
2set -e
3xcrun simctl openurl booted "myapp://home"
4xcrun simctl openurl booted "myapp://cart?coupon=SAVE10"
5xcrun simctl openurl booted "myapp://unknown/path"

Use this in CI with simulator-based UI tests when feasible.

Debug routing failures quickly

If nothing happens, inspect logs from Xcode console and verify URL handler entry points are hit. Also confirm app is installed on the simulator and the scheme matches exactly.

Common Pitfalls

  • Running openurl with a scheme not registered in the app Info.plist.
  • Testing only warm-start behavior and missing cold-start routing bugs.
  • Assuming Universal Links and custom schemes share identical handling paths.
  • Forgetting to URL-encode query parameters in test links.
  • Relying on manual deep-link checks without repeatable scripts.

Verification Workflow

After implementing the main approach, run a short verification loop that proves behavior on realistic and adversarial inputs. Start with a small happy-path sample that should always pass, then add one edge case and one failure case that should be rejected or handled gracefully. Capture concrete outputs instead of relying on visual inspection alone. For operational code, record one measurable signal such as runtime, memory use, or error count so you can compare before and after future refactors.

Use this quick template during local development and CI:

text
11. Prepare deterministic sample input
22. Run expected-success scenario
33. Run expected-edge scenario
44. Run expected-failure scenario
55. Assert output schema and key values
66. Record one performance or reliability metric

This discipline catches most regressions caused by dependency upgrades, environment differences, or hidden assumptions in helper functions. It also makes handoffs easier because another engineer can reproduce behavior quickly without reverse-engineering your intent from source code alone.

Deployment Notes

Before rolling this pattern into production, add one small automated regression check tied to your most critical user path. Keep the check deterministic and fast, and run it on every dependency or configuration change. This extra guardrail catches subtle behavior drift that static review often misses, especially when environments differ between local machines and CI runners.

Summary

Pass deep links into iOS Simulator with xcrun simctl openurl and validate both configuration and routing behavior. Support custom schemes through Info.plist and proper delegate handlers, and treat Universal Links as a separate integration path with associated domains requirements. Script common cases to make regression testing fast and reliable.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.