Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 2.45 KB

AOT.md

File metadata and controls

48 lines (37 loc) · 2.45 KB

Native AOT for this repository

Overview

This repository is a cross-platform wrapper for macOS InputMethodKit. Native AOT produces a native executable for a specific runtime identifier (RID). AOT is most relevant for the sample app (executable), not the library package.

Quick steps

  1. Verify your SDK and workloads:
dotnet --version
dotnet workload install microsoft.net.sdk.macos
  1. Publish a native executable for Apple Silicon macOS:

Option A (recommended): publish for net10.0 TFM with macOS RID — this avoids macOS SDK pack differences while still producing a macOS app bundle when -r osx-arm64 is used:

dotnet publish samples/MinimalSample/MinimalSample.csproj -f net10.0 -r osx-arm64 -c Release \
  -p:PublishAot=true -p:SelfContained=true

Option B (macOS-specific TFM): publish for net10.0-macos if you require the macOS-specific runtime; in that case you may need to configure ApplicationId and/or Info.plist and ensure Xcode tools & provisioning are available. If you see linker errors while optimizing ("No platform assembly"), try the net10.0 option or ensure the workload is installed and the Mac SDK is properly configured.

dotnet publish samples/MinimalSample/MinimalSample.csproj -f net10.0-macos -r osx-arm64 -c Release \
  -p:PublishAot=true -p:SelfContained=true
  1. Find the executable in: samples/MinimalSample/bin/Release/net10.0-macos/osx-arm64/.

Important options

  • PublishAot=true: Enables native AOT compilation.
  • SelfContained=true: Bundles the runtime, resulting in a self-contained executable.
  • TrimMode=link: Enables IL trimming to reduce size; can break reflection-based code.
  • StripSymbols=true: Remove debug symbols to reduce size.
  • RuntimeIdentifier (RID) must match the target platform: osx-arm64 for Apple Silicon, osx-x64 for Intel.

Troubleshooting & tips

  • If you rely on reflection, add DynamicDependency, PreserveDependency or rd.xml based attributes to preserve that metadata for trimming/AOT.
  • For debugging, set SelfContained=false and/or omit PublishAot to run a non-native build.
  • Use -p:PublishSingleFile=false for simpler debugging; single-file bundles may compress and cause startup/perf differences.
  • If you want AOT builds for the library (e.g. to produce a native binary to ship), you'll need to create a small host executable that references the library and publish that executable.