Skip to content

[net11] Class.GetHandle inlining turns nonexistent binding classes into hard link errors (Undefined _OBJC_CLASS_$_* in inlined-class-gethandle.o) on publish #26268

Description

@pshoey

Description

On .NET 11 preview 6 (net11.0-ios, iOS SDK pack 26.5.11720-net11-p6), dotnet publish -c Release fails at the native link with:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_Session", referenced from:
       in inlined-class-gethandle.o
ld: symbol(s) not found for architecture arm64

dotnet build (Debug AND Release) of the same project links fine — only the publish pipeline hits it.

Analysis

The referenced type comes from a third-party binding (Drastic.FFMpegKit 5.1.1) that declares a binding type named Session. In the native ffmpegkit.framework, Session is a protocol, not a class — the exported class symbols are AbstractSession, FFmpegSession, FFprobeSession, MediaInformationSession (verified with nm -gU):

_OBJC_CLASS_$_AbstractSession
_OBJC_CLASS_$_FFmpegSession
_OBJC_CLASS_$_FFprobeSession
_OBJC_CLASS_$_MediaInformationSession

On net10 this binding mistake was benign: Class.GetHandle("Session") was a lazy runtime lookup that either never executed or returned IntPtr.Zero. The new net11 Class.GetHandle inlining (per the generated inlined-class-gethandle.o) turns these lookups into direct _OBJC_CLASS_$_* symbol references, which makes any binding whose named native class doesn't actually exist a hard link failure — even when the type is never used at runtime.

Expected

Either the optimization falls back to runtime lookup (or emits a weak reference) for classes that can't be proven to exist, or this behavioral change is documented as breaking for existing (admittedly imperfect) binding packages — a large ecosystem of third-party bindings will hit this.

Repro

  1. Reference a binding library containing [BaseType(typeof(NSObject))] interface Session {} where no ObjC class named Session exists in the linked native framework (protocol-only name).
  2. dotnet publish -c Release -r ios-arm64 on net11.0-ios p6 → link error above. dotnet build succeeds.

Real-world package that triggers it: Drastic.FFMpegKit.full.ios 5.1.1.

Environment

  • .NET SDK 11.0.100-preview.6.26359.118, net11.0-ios (pack 26.5.11720-net11-p6)
  • Xcode 26.5, macOS Darwin 25.5.0

Activity

  1. pshoey commented on Jul 23, 2026

    @pshoey
    Author

    Narrowed it down further:

    • Repro requires PublishAot=true (NativeAOT). The failing inlined-class-gethandle.o comes from the managed static registrar path.
    • dotnet publish -p:PublishAot=false — which on net11 is the CoreCLR runtime path (Mono is gone in net11 mobile) — links and produces a working IPA from the identical project. That's the practical workaround.
    • -p:MtouchExtraArgs=--optimize=-redirect-class-handles is accepted but does NOT avoid the error, so the class-handle inlining in the managed static registrar appears unconditional rather than gated on that optimization.

    Sharpened summary: the NativeAOT managed static registrar emits hard _OBJC_CLASS_$_* references for binding types whose native class doesn't exist (protocol-only names), breaking publish for existing binding packages. net10 NativeAOT with the same project/publish settings links fine, so this is new in the net11 p6 registrar.

  2. added
    bug
    on Jul 27, 2026
  3. added theissue type on Jul 27, 2026
  4. added this to the .NET 11 milestone on Jul 27, 2026
  5. rolfbjarne commented on Jul 28, 2026

    @rolfbjarne
    Member

    Thanks for the issue! I can confirm the bug, and a fix is in progress.

    I don't know yet if the fix will be in the next preview 7 release, or only the first RC release.

  6. added a commit that references this issue on Jul 28, 2026
    a8f6e4e
  7. added a commit that references this issue on Jul 30, 2026
    07928c6
  8. rolfbjarne commented on Jul 30, 2026

    @rolfbjarne
    Member

    The fix will be included in Preview 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions