Pass deep link into iOS Simulator?

前端 未结 5 596
醉酒成梦
醉酒成梦 2021-01-31 14:32

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 th

相关标签:
5条回答
  • 2021-01-31 14:38

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

    0 讨论(0)
  • 2021-01-31 14:42

    (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.
    0 讨论(0)
  • 2021-01-31 14:43

    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?

    0 讨论(0)
  • 2021-01-31 15:00

    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.

    0 讨论(0)
  • 2021-01-31 15:00

    Here's another approach:

    In the Simulator

    1. Open the Contacts app
    2. Go to one of the pre-defined contacts
    3. Tap Edit
    4. Tap add url - to 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
    0 讨论(0)
提交回复
热议问题