2

I learnt that Xamarin.mobile provides single set of APIs across platforms. But implementing in a cross platform app, how does it look like?

A cross platform architecture consists one project containing shared codes (core project) and other project consisting the UI codes per platform. So, as Xamarin.mobile provides a single set of API, how can we utilise it to write once and use everywhere? Eg: implement mediapicker.TakePhotoAsync in one class and use it in multiple platforms without writing the same code in other platform. Because, the sample app i downloaded from Xamarin.mobile consists of apps developed for different target individually (not cross), though i see they use the same media picker, geolocation and contacts namespace across different platforms.

Thank You!

  • To clarify, Xamarin.Mobile is a specific library included as part of the Xamarin SDK which allows you to access some platform specific features using a common API. It's not clear if your question is about Xamarin.Mobile specifically, or more generally using Xamarin.iOS and Xamarin.Android to do cross platform development. – Jason May 16 '13 at 14:52

1 Answers1

0

Xamarin's 'traditional' approach to cross-platform apps has been to use file-linking.

I believe this is currently changing to a dual approach of recommending either:

  • file-linking

or

  • Portable Class Libraries (PCL)

The first version of Xamarin PCL support is due very soon (any day now).

When that becomes available and stable, then I expect you may see new versions of xamarin.mobile which are available for PCL. Also, they have indicated that they may open source xamarin.mobile. As it stands today, I don't think xamarin.mobile is a very active development - I don't believe it's changed/grown much in the last year.

Until these changes happen, then if you want to use xamarin.mobile from portable code, then your best bet may be to either follow the file-linking route, or to use PCL libraries but use some form of facade to wrap the native xamarin.mobile libraries inside an injectable interface

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • Thanks for the reply. I was choosing Xamarin.mobile to have a single set of API access hoping that would minimize codes and be shared across platforms easily. So, what alternative do you suggest for having a common access to the API that will be supported in PCL? –  May 16 '13 at 14:44
  • I think you know who I am already... so you already know the answer I give... as a clue: starts with mvvm and ends in cross... also please try reading http://stackoverflow.com/faq – Stuart May 16 '13 at 14:49
  • Yes, i know you very much by now :D Thanks a lot, i'll start using the MVVMCross and the plugins (nugets). But using the nuget i face the same problem as in [here](http://stackoverflow.com/questions/16529794/mvvmcross-3-0-6-nuget-package-installation-issue) after trying [this] (http://slodge.blogspot.nl/2012/09/mvvmcross-vnext-portable-class.html). Any suggestion? –  May 16 '13 at 14:57
  • I watched 4 of the starting videos where you don't face the Profile 104 problem (PCL) –  May 16 '13 at 14:59
  • Sorry - comments are not for new questions - not my rules - http://stackoverflow.com/faq – Stuart May 16 '13 at 15:02