Quick way to open a Custom URL Scheme in iOS Simulator

⋅ 1 min read ⋅ Simulator Development

Table of Contents

In the past, the way I test a custom URL scheme is to go to Safari and type in any of my custom URLs in the address bar.

Testing a custom URL scheme with Safari
Testing a custom URL scheme with Safari

This method works, but it is a bit cumbersome. Safari doesn't remember the last custom URL, that's mean you have to type it again and again. And going back and forth between your app and Safari makes things worst.

A better alternative

xcrun is a tool to run any tool inside Xcode from the command line. The tool for this job is simctl, which help you manage simulators.

To open a custom URL scheme (or any website) in a simulator.

  1. Run your app in the Simulator.
  2. Open Terminal.app (located in /Applications/Utilities)
  3. Enter the following command and hit ⏎ Return.
xcrun simctl openurl booted <url>

Example

xcrun simctl openurl booted acme://test

This will simulate what we used to do in Safari, but a lot easier and faster.

Testing a custom URL scheme with simctl
Testing a custom URL scheme with simctl

Read more article about Simulator, Development, or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.

Become a patron Buy me a coffee Tweet Share
Previous
How to renew an expired certificate with Fastlane Match

Fastlane Match saves us a lot of time managing certificates and provisioning profiles, but there is one thing that we have to do it manually. That is a renewal expired certificate. Luckily, we have to do it once a year. Let's learn how to do it.

Next
Move your view around with Drag Gesture in SwiftUI

SwiftUI's UIPanGestureRecognizer equivalent.

← Home