Search code examples
c#iosxamarinmonogamefarseer

How can I add MonoGame.Framework to the Farseer Physics for MonoGame project in Xamarin?


I am using Xamarin 5.9.1 on Mac OS X Yosemite. I have built an iOS game running Xamarin.iOS. I was able to successfully add MonoGame.Framework to my iOS project from NuGet, but now I want to extend it to use Farseer Physics for MonoGame, so I've added the Farseer Physics project to my solution. The Farseer Physics project references MonoGame.Framework, so I've tried to add this framework in from NuGet as well. However, when I try to add it, I get this error:

Could not install package 'MonoGame.Framework.iOS 3.4.0.459'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0,Profile=Client', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

How can I add MonoGame.Framework to the Farseer Physics for MonoGame project in Xamarin?


Solution

  • I just figured it out. Seems to always be the case shortly after I write a question these days! Here's what I did:

    • Add a new project to your solution. Make sure it is an iOS -> Library -> iOS Library Project type. Call it "Farseer" or something similar.
    • Add the MonoGame for iOS NuGet package to this new "Farseer" project.
    • Copy all of the folders and files of the Farseer Physics for MonoGame project into this "Farseer" project.
    • Include this "Farseer" project into your main iOS project or game, and you're set.