Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching for the best PCL profile for cross-platform development

I am working on extending number of supported platforms for my app, it used to support .NET4/Windows Store/Windows Phone, but I hope to also cover Mono for Android and iOS. I've put all business logic, models and view models to portable class libraries (PCL) but it's a big dilemma what subset of platforms I should target. Each combination causes something to fail. Here are the results for 4 platforms that I might use:

Profile 78 (NET45+WP8+Store): no problem with TPL,await/async and support for CallerMemberName attribute (used in BindableBase view model base class). But the Mono.Android project that refers such library fails to build complaining about non-present System.Runtime.dll that should be referenced.

Profile 104 (NET45+SL4+WP75+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 147 (NET403+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

Profile 158 (NET45+SL5+WP8+Store): await/async don't work, CallerMember name not found, but if I remove all references to them, Android project builds fine.

So I am not really sure what to choose. Profiles 78, 104, 147 are limited, profile 78 is the only one that supports both await/async and CallerMemberName used BindableBase, but it fails on Android complaining about System.Runtime.dll. So if you have an experience with what PCL profile is the best match for PCL targeting Mono, please share your thoughts.

like image 585
Vagif Abilov Avatar asked May 09 '13 14:05

Vagif Abilov


1 Answers

Thinking about profile numbers is hard - I prefer to think in terms of the platforms.

Ideally I'd love my projects to support:

  • .Net 3.5 and higher
  • SL3 and higher
  • WP7.x phone and higher
  • MonoDroid 1.6 and higher
  • MonoTouch iOS6 and higher
  • (Mac desktop OSX Lion)

The main PCL project I support is MvvmCross - which requires Mvvm 'facilities' like ICommand. These facilities are only available in platforms for .Net 4.5 and higher... that's a hard limit - nothing I can do about it - so changes my needs to:

  • .Net 3.5 and higher .Net 4.5
  • SL3 and higher SL4 and higher
  • WP7.x phone and higher
  • MonoDroid 1.6 and higher
  • MonoTouch iOS6 and higher
  • (Mac desktop OSX Lion)

With this selection in place, then this leads me to a profile number - 104 (no idea how the platform decided this... gave up asking a long time ago!)

So I've targeted MvvmCross at profile 104 - and it will stay there while WP7.x support is still needed.

This selection does mean that MvvmCross cannot out-of-the-box support things like async/await and CallerMemberName - but this is a compromise we've decided to make - we have users who need WP7.


However, some people are asking about await/async...

To use these new features, there are some BCL.Async Nuget hacks to make them work in profile 104... or these users can target their apps at a newer profile (one that doesn't support WP7.x and SL4) - this leads them to build their apps in profile 78, but to add references to my profile 104 assemblies.

Neither of these sets of solutions works very well with the Xamarin twins at present - e.g. you hit issues like the missing System.Runtime.dll assembly. However, I anticipate that when Xamarin officially supports PCLs (and after some alpha/beta testing) then these problems will be resolved. This official support is due very soon now - which is why I don't bother expending too much of my time thinking about these problems...


I expect in the medium term that MvvmCross will drop support for WP7.x and SL4. When that happens, we may also move the core libraries to profile 78.


The only other large platform I know that has started PCL support is ReactiveUI. I believe this platform must use profile 78 because the PCL version of Reactive from Microsoft is targeting 78.

like image 70
Stuart Avatar answered Nov 06 '22 20:11

Stuart