Note that there are some explanatory texts on larger screens.

plurals
  1. POXamarin & Visual Studio, Windows Phone & ASP.NET: Is a true single class library possible?
    text
    copied!<p>I've currently built a service layer and API which I'm consuming from an ASP.NET website, Windows Phone app, and a Windows 8 metro app - the key to all of them being a project containing model classes which is a portable class library project, and is shared as a reference between all of them. This architecture works fine and without any issues.</p> <p>However, I've recently started experimenting with Xamarin - specifically the iOS functionality (with a view to moving onto Android later). My initial assumption was that I would be able to utilise this model library as I do with the other projects - however, I've since realised this this isn't the case. </p> <p>When I first added a reference to my model class library to my Xamarin.iOS project (in Visual Studio), I was greeted by the error:</p> <p>'The current project does not support references to Portable Library projects'. </p> <p>Strange - as I thought this would be a scenario that would be supported. I found a post <a href="http://slodge.blogspot.co.uk/2013/03/xamarinios-with-mvvmcross-in-vs2012.html">here</a> which suggested a fix that forced Visual Studio to detec the Monotouch (Xamarin) framework as supporting Portable Library Projects. Seemed to be exactly what I needed - but no. When I added the reference again, I was greeted by a different error:</p> <p>'The current project's target framework is not compatible with that of the Portable Library project'. </p> <p>And it suggests I change the target framework in the project properties. Except I can't, as the Xamarin iOS project needs to support Monotouch (and I can't change it to anything else from the GUI anyway). So I tried to change the model library's properties instead - maybe I can do something there. And it looked like I could. I can check Monotouch (Xamarin) as a supported platform here (where Windows phone, Windows store, etc are already checked), but it won't let me save. It just shows the message:</p> <p>'There is no additional functionality that is supported by the target frameworks you have selected'</p> <p>After some research, I discovered that the only way Xamarin suggest to share code is to use separate projects with linked code files (so in effect, a pseudo-single code base. Which I have tried and works - but it seems a hack. See here:</p> <p><a href="http://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options">http://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options</a></p> <p>So is this the only option? Or is there any way to have a <em>true</em> single class (model) library across all platforms, including Microsoft and Xamarin?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload