A minimal C# wrapper for Smush—a tiny Objective-C shim that lets a .NET 8 app detect custom URL-scheme launches on macOS (x64).
- macOS with the Xcode command-line tools installed:
xcode-select --install
- .NET 8 SDK (for
dotnet build/pack/run).
Build the native shim & C# library
From the src/SmushSharp folder:
dotnet build -c ReleaseYou 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.x.x --source .Alternatively, you can get it from NuGet.org:
dotnet add package SmushSharp --version 1.x.xRegister 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 = SmushSharp.DetectLaunchUrl(2.0);
// Your code to handle the URL ...
}
}Run your app:
- Launch your app normally so that macOS can register the URL scheme. If necessary, you can manually register the URL scheme by running:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f <yourAppPath>.app
- If you now launch via
open your-custom-scheme://foo, the URL will be detected by the code.