Jump to content

Issues with development on a Mac using Xamarin


Recommended Posts

Hey,

I've taken over maintaining the ESLD beacons mod and had my build environment working fine for KSP 1.0.5. This was my first time using C# and setting this sort of environment, but it compiled and worked.

Unfortunately, since updating to 1.1 I can get anything to load into the game. Compiling works fine, but I keep getting "System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded." errors in the log from AssemblyLoader related to my dll. I've noticed that UnityEngine.dll has moved from KSP/Data/Managed to KSP/Resources/Data/Managed and there's a second copy of Assembly-CSharp there too. Compounding the problem, I think my version of Mono updated so that could be at play too.

I saw this error once before when I was referencing the wrong .Net version, but I haven't changed that setting in Xamarin since fixing that.

Can anyone tell me what I'm doing wrong? Are there any experienced Mac developers?

I'm referencing the new UnityEngine.dll in /Resources/Data/Managed and the usual Assembly-CSharp in /Data/Managed. I'm compiling in Xamarin studio with the profile "PCL 4.0 - Profile5" which targets .NET 4 or later. I have the newest version of Mono.

Link to comment
Share on other sites

I installed Mono 3.12.1 (which, according to the release notes, is the last supporting .NET 3.5), but now Xamarin won't start, saying "This application requires a newer version of the Mono framework." I emailed the makers of Xamarin asking for a download link to an earlier version that might support Mono 3, but who knows how far that'll go.

What IDEs do other Mac-based developers use? All the guides here talk about Monodevelop, but that's become Xamarin and can't be gotten anymore.

Edited by Booots
Link to comment
Share on other sites

You should be able to have 2 mono install on a system. A mono 4 that would be used to run Xamarin and a 3 that you ask the IDE to use to compile. It is doable on Linux so I guess you can do it on OSX but I can't help much more :(

Link to comment
Share on other sites

  • 8 months later...

Aha! Here's how to get development started on a Mac, as I've just managed to do it.

  1. Download and install an editor/IDE. I chose to use Xamarin Studio Community Edition since I'm not doing any professional C# work.
    1. Upon first running Xamarin Studio, it will prompt you to download Mono. Let it do that.
    2. After the Mono framework package is downloaded, you're going to need to run it as an installer and install it. The readme says that a bunch of libs get installed, and I was initially concerned because they were also libs that I'd installed using MacPorts. However, they are installed inside the Mono framework directory, so there will be no collision. Don't Panic.
  2. Download and install the old version of Mono (3.12.1)
  3. Open a terminal window and cd to /Library/Frameworks/Mono.framework/Versions
    1. Since this is a root-owned directory, easiest thing here is to `sudo -s`
    2. Note that there will be at least two directories in here. One is '3.12.1' and the other is whatever is current at the time you ran Xamarin Studio. As I write this, it's 4.6.2. There is also a symbolic link, Current, that's pointing to the last version you installed, which is probably 3.12.1. If it is, that needs to be changed.
    3. `rm -f Current;ln -s 4.6.2 Current`
    4. Now you can exit the sudo shell
  4. Launch Xamarin Studio
  5. In the application preferences (cmd-,) look in Projects->.NET Runtimes. If the 3.12.1 framework isn't there, you need to add it.
  6. Quit and relaunch Xamarin Studio.

Now you'll be able to set Mono / .NET 3.5 as the target in your project's options.

Link to comment
Share on other sites

Never tried to compile using Xamarin Studio, but I found a process that works with xbuild (command line compiler that comes with mono).  I only ever had to install the latest version of Mono.

xbuild /p:Configuration=Release /p:ReferencePath="path/containing/ksp/assemblies" MySolution.sln

You can of course specify Debug rather than Release.  The path for the assemblies is something like something/KSP.app/Resources/Data/Managed (looks like you figured that out already), or copy the DLLs somewhere else.

Edited by blowfish
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...