We are starting a cross-platform project to be deployed to Android and iOS. Obviously, a lot of code is to be shared between the two, and some of the code relies heavily on the .NET framework items, like sqlite-net library does.
The best way (afaik) to share the code between 2 projects is to use a PCL – this way it is possible to reference the project with shared code from both iOS and Android projects in a solution and have everything re-compiled and linked in a nice manner.
However, a PCL created in MonoDevelop is compiled with gmcs compiler and some of external dependencies fail to be built in this case (i.e. the framework used in this case lacks System.Func<T, TResult>
, providing only System.Func<T1, T2, ..., T9, TResult>
). MonoTouch's compiler (smcs), in its turn, is able to compile the PCL perfectly (proven by replacing gmcs binary with smcs binary). From what I've found after a bit of googling, gmcs uses 2.0 .NET framework, while smcs uses smth called 2.1 framework, which is in fact a cutted mixture of more recent .NETs.
Here comes the question: is it possible to specify which compiler to use while building PCL (as a dependency of another project) in MonoDevelop?
Mono does not yet have an implementation of the actual PCL libraries. For now, it has a dummy Microsoft.Portable.CSharp.targets file that instead overrides the framework and targets to build the library against MonoTouch, Mono for Android or .NET 4.0, in that order, depending what's installed.
It looks like there's bug in the codepath that uses the MonoTouch framework - it's using the default common targets, Microsoft.CSharp.targets, without overriding the compiler to use the MonoTouch-specific version of the C# compiler. This is necessary because Mono's C# compiler is currently framework-specific (though this is fixed in Mono 2.12, which is in alpha).
You may be able to fix this by editing the file /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild/Microsoft/Portable/v4.0/Microsoft.Portable.CSharp.targets
, finding the PropertyGroup that sets
<TargetFrameworkIdentifier>MonoTouch</TargetFrameworkIdentifier>
And to it, adding the lines:
<CscToolExe>smcs</CscToolExe>
<CscToolPath>/Developer/MonoTouch/usr/bin</CscToolPath>
I know this is an old question, but it appears that Portable Class Library (PCL) support was added to Mono in version 3.0.x, see the Release Notes for details, particularly version 3.0.8 :
Added PCL support to xbuild, mono’s MSBuild implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With