Quick way to open a Custom URL Scheme in iOS Simulator

Simulator Development

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

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 Tweet Share

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 — entirely for free.

← Home