135

I would like to find an easier way to call deep links in the iOS simulator.

On Android you can use ADB to pipe links into the simulator by using the console.

Is there a similar way or a workaround to open deep links with the latest iOS Simulator?

pkamb
  • 33,281
  • 23
  • 160
  • 191
patreu22
  • 2,988
  • 4
  • 22
  • 31

6 Answers6

320

You can type this into your Terminal :

xcrun simctl openurl booted '<INSERT_URL_HERE>'

You can even share documents using the builtin Share Extension from the Finder to the iOS Simulator.

musical_coder
  • 3,886
  • 3
  • 15
  • 18
Adam
  • 4,266
  • 1
  • 21
  • 21
45

Here's another approach:

In the Simulator

  1. Open the Contacts app
  2. Go to one of the pre-defined contacts, like "John Appleseed"
  3. Tap Edit
  4. Tap add url (at the bottom) - and set your link as a "homepage" URL for this contact
  5. Tap Done to save the contact
  6. Tap on the link you just added

Pro tip: You can add custom labels to the URL entries, for example if you want to test different URLs and be able to identify them quickly.

Note: If you reset the Simulator, the Contacts app will be reset to default and lose the URL.

shim
  • 9,289
  • 12
  • 69
  • 108
Nikolay Suvandzhiev
  • 8,465
  • 6
  • 41
  • 47
14

As an alternative, you can use ControlRoom open-source tool. Basically it's a wrapper above simulator cli.

ControlRoom Open URL

Jurasic
  • 1,845
  • 1
  • 23
  • 29
5

The cmd Command didn't work?!

Unfortunately, the xcrun simctl openurl booted command didn't work. My link is something like this:

myapp://?p=abc&case=12345

I kept seeing the error of:

MyApp % zsh: no matches found: myapp://?p

Solution

I was able to fix it by:

enter image description here

  • Add your deeplink and tap the "LOAD" button. Therefore it should navigate to:

enter image description here

  • Tap the deep link (the blacked box in the above screenshot).

And that's it!

Note that

if you add the link directly to Safari it won't work as well, make sure you are using the halgatewood.com deep link tester instead.
Ahmad F
  • 30,560
  • 17
  • 97
  • 143
  • 1
    in case you haven't done it, don't forget to put the URL inside quotation marks, I had some problems due to missing it. So in your case, it would be something like: `xcrun simctl openurl booted "myapp://?p=abc&case=12345"` – Ricardo Barroso Aug 04 '22 at 15:45
4

Even though there are a lot of great solutions, I still want to add my 5 cents :)

My approach is based on Automator macOS app and lets you execute any deeplink from your computer on iOS simulator with two clicks.

I’m going to use Quick Actions since in that case, we can use any application to get URLs from. So, start the app, File —> New —> Quick Action —> Choose. Now drag and drop your first action. It’s going to be Set Value of Variable. Go to the View menu and select Variables. Inside variables section make the right-click and select New variable. Name it something like url. We are going to keep input text (which is supposed to be our deeplink) in that variable. Now drag and drop Run Shell Script action, make sure that Pass input parameter set to “as arguments”. Paste the following line:

xcrun simctl openurl booted $1

where $1 is going to be our URL variable.

This is how it should look like:

Now save this action as Open in Simulator. This action is now available in the Services context menu. Select any URL as a text in any app, right-click, Open in Simulator - neat right?

Sapozhnik Ivan
  • 235
  • 3
  • 7
2

(Tested for Branch.io QuickLinks)

Another very simple method of opening deeplinks in iOS simulator is:

  1. Copy the deeplink to clipboard.
  2. Open Safari application in your iOS simulator and paste your deeplink url in safari.
  3. Safari will try to open the url but it will fail, showing an error alert. But don't worry.
  4. Open your application, by running it from Xcode, simulator will think the app is opened from deeplink and you will receive required deeplink information in your code.
Hassaan Fayyaz
  • 189
  • 1
  • 4
  • I there any way to open Branch.io link directly on the simulator link android Emulator support. – Nivrutti Pawar Oct 09 '20 at 04:57
  • 1
    Yes, in iOS 14 and onwards apple has provided the support for opening deeplinks directly in simulator. Simply run the following command in terminal to open app from branch.io deeplink `xcrun simctl openurl booted https://branch.app.link/someBrachDeeplink` – Hassaan Fayyaz Apr 22 '21 at 13:21