Forum Cross Platform with Xamarin

Building a cross-platform project using protobuf-net

So, the latest update has left me in a bit of a predicament in that I cannot seem to get our build working for iOS, and a deadline is approaching. Before the update, I could (perhaps wrongly, but still) include references to dll's that were not built for Xamarin.iOS, at least as long as I did not use features not supported by the platform. The reason this was crucial is our project structure, which included four projects built in the following order:

1) A normal mono library project containing our DTO's as defined by some .cs files built with and for protobuf-net.

2) A simple console application that loads the dll built in step 1) and builds a precompiled, lightweight dll for serialization/deserialization of objects as described here: (never mind that it's regarding Unity, the process was valid for Xamarin.iOS before the update)

3) A normal mono library project containing code shared between our iOS/Android projects, including the server communication and data handling, therefore needing references to the dll from 1) and the generated serializer from 2)

4) The Xamarin.iOS project, referencing the dll from 1) and the dll from 3)

With the new update, dll's included in a Xamarin.iOS project MUST be compiled specifically for Xamarin.iOS, or compile errors arise as discussed in this thread:

Switching the type of projects 1) and 3) to Xamarin.iOS library projects is no problem, but when running the executable from 2) it fails - which makes sense, since the dll it uses to generate the serializer is now built for another platform. If I change the small project from 2) into a Xamarin.iOS project, it builds fine but when I try to run it, it launches the iOS simulator and I can't think of a way to run the executable from command line.

I have also tried to change project 1) and 3) into Xamarin.iOS projects, while keeping the console application from 2) to standard mono. The project would then reference the exact same source code included in project 1) and build the serializer from this instead of loading the assembly from 1). The serializer is generated fine, but fails on runtime because of some UnexpectedTypeErrors, that I suppose are caused by the DTO types from 1) and the serializer being built for different platforms.

Do you see any way of fixing this? Until then, is there any way to downgrade Xamarin.iOS to the earlier version, so that I may at least build until I come up with a better build process for our solution?


  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai

    At the moment the easiest way to handle this might be just to keep 2 copies of the project file for the shared project: one for Xamarin.iOS and one for desktop Mono. See also the Xamarin guide on sharing code.

    If you have Visual Studio Pro, you could also try converting your shared project to a PCL project. Xamarin can consume PCL DLLs, but it cannot yet create them.

    You could downgrade Xamarin.iOS by downloading and installing an older version from the Downloads page on:

    But it's probably best to stay with the most recent version if possible, especially to take advantage of bug fixes.

Sign In or Register to comment.