Working with universal links on iOS simulator

Ilter Cengiz
Objective Tidbits
Published in
2 min readJun 8, 2017
Photo by Kyle Glenn on Unsplash

We can use web URLs for opening content in an application for a while. The setup is very basic. Just write the domains you want to handle in you entitlements file and you’re good to go! (Focusing on the iOS side, skipped domain setup.) From now on, your users can open your application with your links to your domain.

Apart from opening the application we also need to handle the action. So you need to publish a URL like www.example.com/contents/3 and when this URL is opened on the device, you expect the application to, as you can guess, open the content screen for the content whose id is 3.

Also I’m skipping how to handle this action, because it really depends on the setup and/or architecture of your application. I’m just going to focus on testing this feature, on iOS simulator.

We have to have the URL written somewhere on the device, be it an SMS message, an email, and/or a note. Since these are limited/not available on the iOS simulator, we need some other way to test universal links.

xcrun to the rescue

xcrun supports opening URLs on iOS simulator as if they have been triggered by a user action.

xcrun simctl openurl booted “https://www.example.com/content?id=2”

URL can also be written without the quotes but if you have query parameters in it, it will simply fail. But if it’s a plain URL, like so:

xcrun simctl openurl booted https://www.example.com/faq

you are good to go. We can also use app schemes as well:

xcrun simctl openurl booted “exampleapp://example/content?id=2”

So if you’re having all your USB ports plugged in with other stuff like me, you can test universal links on iOS simulator using xcrun!

--

--

Ilter Cengiz
Objective Tidbits

iOS developer at Careem. Writes at @objtidbits. Hobbyist photographer. Pokémon master, Nintendo addict.