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.
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.
- Run your app in the Simulator.
- Open Terminal.app (located in /Applications/Utilities)
- Enter the following command and hit ⏎ Return.
xcrun simctl openurl booted <url>
xcrun simctl openurl booted acme://test
This will simulate what we used to do in Safari, but a lot easier and faster.
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