Search code examples
xamarinxamarin.formsxamarin.androidxamarin.iosnuget

Install Nuget on Xamarin.Forms for every proyect or not


When you install a nuget in Xamarin.Forms is it necessary to do it on every project (project, project.Android and project.IOS)?

Which pros and cons has do it or how I know where I have to intall each of them?


Solution

  • There is no absolute answer, it will depend on the Nuget Package. So you will have to read the information about it before deciding to install it in your project.

    What defines this?

    Take for example Xamarin.Essentials, it is installed in all the projects because you can call the functions in share code, but the actual implementation is in the platform specific. In this case you even have to call Init in every platform

    From Xamarin.Essentials doc

    In the Solution Explorer panel, right click on the solution name and select Manage NuGet Packages. Search for Xamarin.Essentials and install the package into ALL projects including Android, iOS, UWP, and .NET Standard libraries.

    If you apply platform specific code, you might need some extra Nugets for that code, meaning that you would only add it to your Android or iOS or UWP code

    If you have any doubt about where to install the package, you can always ask :) Also if you install an Android package in an iOS project, you surely will get a compiling error.