How to Test Universal Link Handling on macOS
While implementing universal link support for Macrowave, I learned how to quickly test how my app handles receiving a URL using openURL
and onContinueUserActivity
. While I am using SwiftUI the AppKit version of this also works.
There are 2 useful variations:
Accepting the Path to Your App
open -a /Users/lucas/Library/Developer/Xcode/DerivedData/Macrowave-fxywunnkqduudvbrdriarmllzwxx/Build/Products/Debug/Macrowave.app "https://macrowave.co/lucas/dev"
Accepting the Bundle Id of Your App
open -b com.lucas-fischer.Macrowave "https://macrowave.co/lucas/dev"
Before I knew about the open
command testing URL handling was tricky, especially if I had the production version of my app installed on the same Mac. When triggering the universal app from the Notes app for example it would always open the production version and not the version that I am currently working on in Xcode.
Now I can just use open -a
to quickly test my development build.