Why does none of my Binding.iOS project work?

Toine_de_BoerToine_de_Boer NLUniversity ✭✭

Can’t get any Binding.iOS project to work.

I have been trying the example iOS Binding project from: https://github.com/xamarin/ios-samples/tree/master/InfColorPicker/InfColorPickerBinding That basically is the result of the official Xamarin iOS Binding tutorial: https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/walkthrough?tabs=windows#create-a-xamarinios-binding-project

It builds perfectly, like my other custom binding projects do, but when I reference it in a Xamarin iOS project then no methods, properties or enums are exposed.

Is the documentation/tutorial still valid on docs.microsoft, has there been breaking changes in Xamarin versions? Or am I doing something else wrong? (I use the exact same code as https://github.com/xamarin/ios-samples/tree/master/InfColorPicker/InfColorPickerBinding )

PS: when building the Binding project it gives no errors end produces a 500kb dll in the bin. But when using the dll it seems to be empty in a iPhone project (also in the object browser)

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Have you noticed the namespace ?

    Refer here : https://forums.xamarin.com/discussion/comment/362254/#Comment_362254

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭
    edited February 18

    I tried changing the Namespaces a few times and fully rebuilded (incl cleaning the .bin) the project but still the binding project dll is totaly empty.

    PS: I'm using the example project from github. thinking, If I can make it work, I can make one myself.
    https://github.com/xamarin/ios-samples/tree/master/InfColorPicker/InfColorPickerBinding

    using:
    Xamarin 4.12.3.79 ([email protected])
    Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

    Xamarin Designer 4.16.13 (45a16efd4)
    Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

    Xamarin.iOS and Xamarin.Mac SDK 12.2.1.12 (65ec520)

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭

    Very strange, Visual Studio editor gives a lot of not resolve reference errors.
    But when the app is started on an iPhoneSimulator everything seems to work, but breakpoint aren't hit.

    Still, the code isn't editable because VS can't find anything.

    Any idea how to solve this?
    Starting my own Binding iOS project is unworkable this way.

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭

    Just checked the project on VS on a Mac, and there it just works fine.

    How come? it still doesn't work in the newest VS on Windows.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited February 19

    I will try it on my side and let you know the result.

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭

    @ColeX said:
    I will try it on my side and let you know the result.

    That would be great!

  • ColeXColeX Member, Xamarin Team Xamurai

    It works fine on my side ,see the screen shot below

    I've attached the binding project with the .a file , you can try it .

    I suggest you review the official tutorial , don't miss any steps.

    My first guess is that you forget modify the Linkwith.cs ,it should be

    [assembly: LinkWith ("libInfColorPickerSDK.a", SmartLink = true, ForceLoad = true)]
    

    Refer : https://docs.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/walkthrough?tabs=windows#including-the-static-library-in-the-binding-project

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭
    edited February 20

    @ColeX said:
    It works fine on my side ,see the screen shot below

    I tried your BindingSample.zip exactly how it is, just adding it as reference to an iOS project and again it doesn't work.
    It builds, but the iOS project shows its empty.
    BUT, i looked at your .bin folder to reference your created dll. And that worked fine in the iOS project !

    So it looks like my machine is not able to build iOS binding projects correctly.
    Therefore I added a lot of 'C' components with the VS installer, and I disabled Resharper. But no luck, same result.

    I noticed that your zip file contained a __MACOSX folder, did you build it on a MAC ? because the issue is happening on a windows device.

    I added my project in a zip, with your binding project added to it.
    Would you like to try and build it on your Windows device and check if the iOS project van work with this?

    And many thanks for your support.

    PS: I also tried different settings in Linkwith.cs, but no luck.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited February 20

    @Toine_de_Boer said:

    @ColeX said:
    It works fine on my side ,see the screen shot below

    I tried your BindingSample.zip exactly how it is, just adding it as reference to an iOS project and again it doesn't work.
    It builds, but the iOS project shows its empty.
    BUT, i looked at your .bin folder to reference your created dll. And that worked fine in the iOS project !

    So it looks like my machine is not able to build iOS binding projects correctly.
    Therefore I added a lot of 'C' components with the VS installer, and I disabled Resharper. But no luck, same result.

    I noticed that your zip file contained a __MACOSX folder, did you build it on a MAC ? because the issue is happening on a windows device.

    I added my project in a zip, with your binding project added to it.
    Would you like to try and build it on your Windows device and check if the iOS project van work with this?

    And many thanks for your support.

    PS: I also tried different settings in Linkwith.cs, but no luck.

    The dll was built on Windows..I just created the project on mac and copy it to Windows.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited February 20

    I compared your binding project with mine, i found AssemblyInfo.cs is missing in your project .

    Could you create a new library ,add the .a file and rebuild the dll ?

  • ColeXColeX Member, Xamarin Team Xamurai

    Refer http://www.infobrother.com/Tutorial/Xamarin/Xamarin-assemblyinfo-file

    AssemblyInfo.cs is used to define Assembly information , so the iOS application won't find your dll without it .

  • Toine_de_BoerToine_de_Boer NLUniversity ✭✭

    @ColeX said:
    I compared your binding project with mine, i found AssemblyInfo.cs is missing in your project .

    Could you create a new library ,add the .a file and rebuild the dll ?

    I Created a new project like you asked, including the AssemblyInfo.cs but still the iOS Project doesn't see anything from the iOS binding project. (same thing when using your project)

    I was testing on a Mac, and then everything works fine, even when I copy the solution from the Windows device to the Mac and building it without changing anything.
    When I the pick the created dll from the iOS binding bin folder and copy it to the Windows device and use it in the iOS UI Project....... then the iOS UI project suddenly can use the dll.....

    Meaning, I must do all development for the iOS binding project on a Mac. Then create builds/releases and use this dll directly in the iOS Project on the windows devices.

    Unfortunately referencing to iOS binding projects all end-up with empty referenced namespaces.

    Thanks for your help, at least I do have a way to create iOS binding projects now.

Sign In or Register to comment.