3

I'm trying to build a game for iOS with XNA and Farseer Physics 3.3, using ExEn and MonoTouch. In theory this should work fine, but I'm having trouble getting Farseer to work on the iPhone.

I compiled Farseer for MonoTouch/ExEn, and it works great in the iPhone Simulator. But as soon as I switch to the actual iPhone, my project no longer compiles. The problem appears to be happening with the MonoDevelop linker. The compiler bombs out with the message "mtouch exited with code 1", and I get the following linker error output: http://pastebin.com/y62ykJP2. If I disable linking in the project options, the application compiles and deploys to the iPhone, but then crashes.

If I comment out all of the code that instantiates objects defined by Farseer, I don't get any linker errors, and the program deploys and runs just fine. So the problem is clearly with my build of Farseer for MonoTouch.

Unfortunately, I have no idea where to go from here. Where should I start looking with a linker error like this? Or, even better: Has anyone successfully compiled Farseer 3.3 and used it with MonoTouch and ExEn?

Michael
  • 1,968
  • 4
  • 24
  • 40

1 Answers1

2

You're trying to use an assembly compiled for .NET 4.0 in MonoTouch. This will not work (the linker exception you get is because the assembly references a method that does not exist in MonoTouch).

The solution is to compile all assemblies you reference using MonoTouch. Look around to see if anybody already has created a MonoTouch project for Farseer, otherwise you'll have to create one yourself.

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • Interesting. Thank you for your response! Can you point me in the right direction on how to correctly compile an assembly using MonoTouch? Here's the thing: I *did* compile it with MonoTouch. I created a new empty Mono C# Class Library project in MonoDevelop, copied all of the Farseer source files into it, added (what I thought were) MonoTouch-appropriate references, and built it. And that's the DLL that I'm including in my MonoTouch app, which is why it works with "iPhoneSimulator" in MonoDevelop. Am I missing something? – Michael Jan 31 '12 at 16:37
  • @Michael: you shouldn't be getting that linker exception if all your references are compiled using MonoTouch. In that case I recommend filing a bug at http://bugzilla.xamarin.com with a complete test case (you can attach your entire project and mark the bug as private, that way nobody but Xamarin employees will have access to your project). – Rolf Bjarne Kvinge Jan 31 '12 at 21:50
  • 1
    You were exactly right! It turns out that the project that I created in MonoDevelop to compile the Farseer assembly was a "Mono C#" class library instead of a "MonoTouch for iPhone" class library. What a difference a few little words make! Creating a new class library project for "MonoTouch for iPhone" fixed everything beautifully. The Farseer assembly now loads correctly. Thank you! – Michael Feb 01 '12 at 00:23