locked
Referencing Xamarin.iOS.dll and MonoAndroid.dll in Forms project? RRS feed

  • Question

  • User372105 posted

    Is it possible to reference Xamarin.iOS.dll and MonoAndroid.dll in Forms project?

    I believe it was possible until recently in Visual Studio for Mac - but I might be mistaken. Also is it a limitation of the IDE or is there an actual architectural hinder to be able to do it?

    Thursday, August 15, 2019 5:33 PM

Answers

  • User74518 posted

    You should have used then Shared library instead of .NET Standard when creating the project. In Shared library you can access all platforms (and differentiate between them with #ifdefs), as the Shared library code is not in an assembly itself, but will get compiled with each platform during building.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, August 15, 2019 6:07 PM

All replies

  • User2148 posted

    I think these dll should be in platform specific projects. Why should you use them in XF project?

    Thursday, August 15, 2019 5:39 PM
  • User372105 posted

    I am trying to get a shorter way of interacting with native code.

    Primarily I am looking to build multi targeted libraries in VSfM. I would like to be able to add new functionality on existing forms controls without having to subclass them. So I have created a platform-specific extension method that gives me UIKit.UIView on iOS - that possibly then can be cast down to it's specific native control. However I can't interact with it from Forms project or a NetStandardLibrary.

    When it comes to using it directly in Forms I am not sure though its completely beneficial. I was looking for a way it can be done in another mobile framework called NativeScript. However interacting with the native object might be cleaner when done via DependencyInjection. There will regardless be a benefit since a NuGet custom control could be downloaded - and then changed natively (at runtime).

    I think I will have use DependencyInjection via the platform specific projects to test it.

    Thursday, August 15, 2019 6:05 PM
  • User74518 posted

    You should have used then Shared library instead of .NET Standard when creating the project. In Shared library you can access all platforms (and differentiate between them with #ifdefs), as the Shared library code is not in an assembly itself, but will get compiled with each platform during building.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, August 15, 2019 6:07 PM
  • User372105 posted

    @Amar_Bait said: You should have used then Shared library instead of .NET Standard when creating the project. In Shared library you can access all platforms (and differentiate between them with #ifdefs), as the Shared library code is not in an assembly itself, but will get compiled with each platform during building.

    Great! That will make it easier to test my platform-specific

    Thursday, August 15, 2019 6:18 PM
  • User372105 posted

    @Amar_Bait said: You should have used then Shared library instead of .NET Standard when creating the project. In Shared library you can access all platforms (and differentiate between them with #ifdefs), as the Shared library code is not in an assembly itself, but will get compiled with each platform during building.

    And what about in Visual Studio in Windows? I can't see that Shared Library/.Net Standard option.

    Friday, August 16, 2019 7:35 AM