Simple macOS URL-scheme handler shim for .NET 8 (x64)
$ dotnet add package SmushSharpA minimal C# wrapper for Smush—a tiny Objective-C shim that lets a .NET 8 app detect custom URL-scheme launches on macOS (x64).
xcode-select --install
dotnet build / pack / run).Build the native shim & C# library
From the src/SmushSharp folder:
dotnet build -c Release
You can find the output in bin/Release/net8.0
Once you’ve packed, you can install the nuget package like this:
# from your own .NET app folder
dotnet add package SmushSharp --version 1.0.0 --source .
Register your URL scheme in your Info.plist (inside your .app bundle):
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.yourcompany.yourapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>your-custom-scheme</string>
</array>
</dict>
</array>
Call DetectLaunchUrl early in your Main:
using SmushSharp;
class Program
{
static void Main(string[] args)
{
// Wait up to 1 seconds for a URL
string? launchUrl = UrlDetector.DetectLaunchUrl(2.0);
// Your code to handle the URL ...
}
}
Run your app:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f <yourAppPath>.app
open your-custom-scheme://foo, the URL will be relayed into your C# callback.