Binding Objective-C Library gives "Unknown attribute ObjCRuntime.DesignatedInitializerAttribute" err

WD40WD40 USMember ✭✭

Hi all,

I'm attempting to create a binding library for an Objective-C and C++ iOS framework. My steps:

  1. Created a new Binding Library project in OSX Visual Studio
  2. Added my *.framework to bind as a Native Reference.
  3. Ran Objective Sharpie command-line tool to create my ApiDefinition.cs file
  4. Built the project in VS, received an error:

    BTOUCH : error BI1007: btouch: Unknown attribute ObjCRuntime.DesignatedInitializerAttribute on MyFrameworkBindingLibrary.MyClass.Constructor

Btouch's parameters from the build log:

    Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/btouch-native execution started with arguments: 
/v 
/baselib:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll 
/unsafe 
/d:"__MOBILE__;__IOS__;__UNIFIED__;DEBUG" 
/path/to/my/project/ApiDefinition.cs
/path/to/my/project/StructsAndEnums.cs
-r /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/mscorlib.dll 
-r /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.dll 
-r /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll 
/tmpdir:/path/to/my/project/obj/Debug/ios/ 
/sourceonly:/path/to/my/project/obj/Debug/ios/sources.list 

The declaration in ApiDefinition.cs that errors is this:

    namespace MyFrameworkBindingLibrary
    {
        ...

        using ObjCRuntime;

        ...

        // -(instancetype _Nonnull)initWithLocations:(NSArray<MyClass *> * _Nonnull)locations __attribute__((objc_designated_initializer));
        [Export("initWithMyClasses:")]
        [DesignatedInitializer]
        IntPtr Constructor(MyClass[] myObjects);

        ...
    }

Any ideas why this error is showing? I disassembled the Xamarin.iOS.dll and could see the ObjCRuntime.DesignatedInitializerAttribute class, so I'm confused why it says it doesn't know that attribute.

Thanks,
Wyatt

Posts

  • WD40WD40 USMember ✭✭

    Stupid mistake: my StructsAndEnums.cs file's "Build Action" setting was ObjcBindingApiDefinition. After switching it to ObjcBindingCoreSource the build is now working.

Sign In or Register to comment.