Xamarin-macios: Problem building a iOS Bindings Library project

Created on 9 Jul 2018  路  1Comment  路  Source: xamarin/xamarin-macios


hia,

i am currently working on Xamarin ios project for which i need to connect to NordicID EXA051 rfid reader. i got the sdk from their website and ran the objective sharpie command to create bindings.
(https://github.com/NordicID/nur_sample_ios)

i tried creating a bindings library but i was getting thousands of errors. i commented lot of code and made some changes to remove all the compilation errors. however, now when i build it, i am getting errors in file trampolines.g.cs and supportdelegates.g.cs which i have no clue of.

kindly suggest me what is wrong in my project?

kind regards,
Atin..

Steps to Reproduce

  1. clicking build gives 129 errors in Trampolines.g.cs and SupportDelegates.g.cs


    1. 3.

Expected Behavior

Actual Behavior

Environment

=== Visual Studio Community 2017 for Mac ===

Version 7.5.3 (build 7)
Installation UUID: 8fa535d8-1342-4cf8-8fe2-5c63093228c8
Runtime:
Mono 5.10.1.57 (2017-12/ea8a24b1bbf) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 510010057

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.1
2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.301/Sdks
SDK Versions:
2.1.301
2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.4.1 (14161)
Build 9F2000

=== Xamarin.Mac ===

Version: 4.4.1.193 (Visual Studio Community)

=== Xamarin.iOS ===

Version: 11.12.0.4 (Visual Studio Community)
Hash: 64fece5f
Branch: d15-7
Build date: 2018-05-29 20:00:44-0400

=== Xamarin.Android ===

Version: 8.3.3.2 (Visual Studio Community)
Android SDK: /Users/atinagarwal/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705030007
Git revision: 13cecd02aceddf29a1ed57b86f81c02994df1483
Build date: 2018-06-14 15:48:08-04
Xamarin addins: 7065de97cf22c9038fdc39dd627f2c30790fd8af
Build lane: monodevelop-lion-d15-7

=== Operating System ===

Mac OS X 10.13.5
Darwin 17.6.0 Darwin Kernel Version 17.6.0
Tue May 8 15:22:16 PDT 2018
root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.5.3


Build Logs


BuildLogs.txt

Example Project (If Possible)

BindingsTest.zip

iOS question

>All comments

Hello, first a disclaimer here

This means that the output of ObjectiveSharpie won't work out of the box unless you have a very solid understanding on how a binding project works which is fully explained in the following documentation:

Also you need to review our ObjectiveSharpie documentation https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/binding/objective-sharpie/?context=xamarin/mac

That said looks like you got into a generator limitation, each time you find nested blocks you need to split them into two C# delegates as show below, these fixes should get you further:

    // Old:
    //delegate void UIContextualActionHandler(UIContextualAction arg0, UIView arg1, Action<bool> arg2);
    // New:
    delegate void UIContextualActionHandlerBool (bool arg1);
    delegate void UIContextualActionHandler (UIContextualAction arg0, UIView arg1, [BlockCallback] UIContextualActionHandlerBool arg2);


Change this from:

        // -(instancetype _Nonnull)initWithPreparationHandler:(void (^ _Nonnull)(UICloudSharingController * _Nonnull, void (^ _Nonnull)(CKShare * _Nullable, CKContainer * _Nullable, NSError * _Nullable)))preparationHandler;
        [Export("initWithPreparationHandler:")]
        IntPtr Constructor(Action<UICloudSharingController, Action<CKShare, CKContainer, NSError>> preparationHandler);

To:

    delegate void UICloudSharingControllerPreparationHandler2 (CKShare share, CKContainer container, NSError error);
    delegate void UICloudSharingControllerPreparationHandler (UICloudSharingController arg1, [BlockCallback] UICloudSharingControllerPreparationHandler2 arg2);

//...

        // -(instancetype _Nonnull)initWithPreparationHandler:(void (^ _Nonnull)(UICloudSharingController * _Nonnull, void (^ _Nonnull)(CKShare * _Nullable, CKContainer * _Nullable, NSError * _Nullable)))preparationHandler;
        //[Export("initWithPreparationHandler:")]
        //IntPtr Constructor(Action<UICloudSharingController, Action<CKShare, CKContainer, NSError>> preparationHandler);

        [Export ("initWithPreparationHandler:")]
        IntPtr Constructor (UICloudSharingControllerPreparationHandler preparationHandler);

Also you need to add

    delegate void NSItemProviderRegisterDataHandler2 (NSData data, NSError error);
    delegate NSProgress NSItemProviderRegisterDataHandler ([BlockCallback] NSItemProviderRegisterDataHandler2 arg1);

    delegate void NSItemProviderRegisterFileHandler2 (NSUrl url, bool arg2, NSError error);
    delegate NSProgress NSItemProviderRegisterFileHandler ([BlockCallback] NSItemProviderRegisterFileHandler2 arg1);

And change

        [Watch(4, 0), TV(11, 0), Mac(10, 13), iOS(11, 0)]
        [Export("registerDataRepresentationForTypeIdentifier:visibility:loadHandler:")]
        void RegisterDataRepresentationForTypeIdentifier(string typeIdentifier, NSItemProviderRepresentationVisibility visibility, Func<Action<NSData, NSError>, NSProgress> loadHandler);

        [Watch(4, 0), TV(11, 0), Mac(10, 13), iOS(11, 0)]
        [Export("registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler:")]
        void RegisterFileRepresentationForTypeIdentifier(string typeIdentifier, NSItemProviderFileOptions fileOptions, NSItemProviderRepresentationVisibility visibility, Func<Action<NSURL, bool, NSError>, NSProgress> loadHandler);

To:


        [Export ("registerDataRepresentationForTypeIdentifier:visibility:loadHandler:")]
        void RegisterDataRepresentationForTypeIdentifier (string typeIdentifier, NSItemProviderRepresentationVisibility visibility, NSItemProviderRegisterDataHadler loadHandler);

        [Export ("registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler:")]
        void RegisterFileRepresentationForTypeIdentifier (string typeIdentifier, NSItemProviderFileOptions fileOptions, NSItemProviderRepresentationVisibility visibility, NSItemProviderRegisterFileHandler loadHandler);

Now, we currently do not offer binding 3rd party libraries support in our GitHub Issues tracker, the broader developer community would be the best and quickest place for additional troubleshooting help on this issue.
Posting a question on Stack Overflow [0] or the Xamarin Forums [1][2] would be the best next step.

[0] https://stackoverflow.com/questions/tagged/xamarin
[1] https://forums.xamarin.com/categories/ios
[2] https://forums.xamarin.com/categories/mac

In case it might also be a helpful reference, you can find some general recommendations on the best places to ask various kinds of questions about Xamarin on:

https://developer.xamarin.com/guides/cross-platform/troubleshooting/support-options/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cwensley picture cwensley  路  3Comments

sharmashiv picture sharmashiv  路  4Comments

nickmask picture nickmask  路  3Comments

juepiezhongren picture juepiezhongren  路  3Comments

ormaa picture ormaa  路  3Comments