Search code examples
xamarinvisual-studio-mac

How to have Xamarin library project reference another library project


I have created a solution in Xamarin (Visual Studio for Mac) that has:

MyGame (solution)
> MyGame
> MyGame.Droid
> MyGame.IOS
> MyLibrary   <= this contains additional code to be used by MyGame

The odd thing is that if I open MyGame.Droid or MyGame.IOS there is a references folder where, for example, the MyGame project is referenced.

But, when I open up MyGame there is no References folder.

How do I add a reference in MyGame to MyLibrary?


Solution

  • Add the new project reference MyLibrary to both MyGame.Droid and MyGame.IOS projects.

    It seems you've created a Xamarin.Forms project and then created a .NET Standard library project. By default Xamarin.Forms create a Shared project which means it is shared between MyGame.Droid and MyGame.IOS and whenever you build the Droid it becomes to be a part of the droid project and opposite for the iOS project.

    As an alternative, you can convert your Shared project to the .NET Standard and then you will be able to add required references.