mauimaui-community-toolkit

Undefined symbols for architecture arm64 - Native Library Interop


I'm building a MAUI app that includes a NativeLibraryInterop based closely on the Firebase sample.

The NativeLibraryInterop project builds successfully. However, when I build the apps project itself, I get a bunch of errors related to the interfaces.

clang++ exited with code 1:
// a path
"OBJC_CLASS$_MauiFIRApp", referenced from:
// a path
error : Undefined symbols for architecture arm64:

How do I fix this?


Solution

  • Add the [Protocol] attribute to each interface that is referenced in the "Undefined symbols for architecture arm64" errors.

    From:

    [BaseType (typeof(NSObject))]
    interface MauiFIRApp
    {
        // Interface code
    }
    
    

    To:

    [Protocol]
    [BaseType (typeof(NSObject))]
    interface MauiFIRApp
    {
        // Interface code
    }
    

    Then rebuild your NativeLibraryInterop project. If migrating between .Net versions / xcode versions, you might need to rebuild the native library as well 🤷‍♀️