Portability: MonoTouch, MonoDroid, and PCLs

In my team’s most recent client work, we’ve been tasked with cross platform mobile development. It is an extremely fun project with an aggressive timeline. Some of the technologies involved so far are:

Beginning Ideas

Use iFactr to programmatically build layers (screens / views) for our application. iFactr works off of the Xamarin framework, so we have the ability to make small tweaks to each version of the application (iOS / Android).

Advantages

  • One code base – multiple platforms: iOS and Android

Disadvantages

  • Quirkiness of two project files with shared iFactr code – setup and maintenance of an Android and iOS version of (almost) identical projects was difficult – think namespace, file link, reference issues
  • Testability of application and business logic – only certain types of projects can reference Xamarin – unit tests only available for iOS and must be run on device (or simulator)
  • Restriction to iFactr deployment platforms (yes, there are several but why restrict yourself?)

New Ideas – MVVM and PCLs

Use Model-View-ViewModel concepts and portable class libraries to expand and better our solution. Move all models and view models to a portable class library, along with custom defined application service interfaces. Implement services in the same project, but have the ability to later leverage dependency injection for a modular solution.

Advantages

  • One code base – more platforms: iOS, Android, Windows 8, WinPhone, WPF, Xbox360, etc.
  • Testability of application – standard MSTest projects that reference PCLs to test functionality

Disadvantages

  • Learning curve – setting up a PCL for MonoTouch, MonoDroid, and .NET assemblies is not a trivial task – there isn’t a step by step guide out there

As mentioned, there isn’t a step by step guide anywhere but I did find some extremely helpful resources from this blog by Stuart Lodge.

I’m happy with where we’ve taken the solution. I plan to continue learning about PCLs and portability in general. My goal for this year is to make some type of applications that ports to all the platforms listed above (and possibly more).

Posted in Professional Tagged with: , , , , , ,
4 comments on “Portability: MonoTouch, MonoDroid, and PCLs
  1. rosswright says:

    So, looking forward to your next post, a step-by-step guide to using a PCL for MonoTouch/Droid and .NET Assemblies. 😀

    • brhlavinka says:

      Yes, this is one that I would definitely like to do. Just need to find some time! Basically I created a PCL profile from scratch so that it could deploy to the devices. Otherwise it tries to use the actual .NET assemblies.

      • slodge says:

        You should be able to just reuse an existing profile – e.g. 104 – it’s what MvvmCross does – and that’s now in lots of apps.

        Also, please don’t document too much right now – I have a feeling *everything* is about to change…

        • brhlavinka says:

          Yep, I actually ended up using an existing profile as a template.

          We’ve gotten hints from iFactr & Xamarin discussions that things might change soon (in regards to portability / PCLs).

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Subscribe to my Insights via Email

Join 61 other subscribers

%d bloggers like this: