Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cross-Platform Mobile Development using Visual ...

Cross-Platform Mobile Development using Visual Studio and Xamarin

Cross-Platform Mobile Development using Visual Studio and Xamarin

Shravan Kumar Kasagoni

May 12, 2016
Tweet

More Decks by Shravan Kumar Kasagoni

Other Decks in Technology

Transcript

  1. Shravan Kumar Kasagoni Senior Developer - RealPage Microsoft MVP –

    VSDT Microsoft User Group Hyderabad @techieshravan
  2. Approaches for device development Native Hybrid Tool maturity Device optimized

    experience Updatability Portability across devices
  3. Using the platform’s native tools (Siloed approaches are long term

    problems) Xcode ADT Visual Studio End user experience Better productivity and global developer experience ✗ Building native apps multiple times when targeting multiple platforms! …very expensive, not sustainable… + + -
  4. What is Mono? • Open source implementation of the .NET

    platform created by Ximian (ECMA 334/335) • 2001: Created to bring Windows applications to Linux • 2003: Acquired by Novell with Ximian • Matured at Novell in research mode; now a world-class runtime.
  5. .NET on Android, iOS Linux Mono iOS Mono Touch Android

    Mono for Android iOS Xamarin.iOS Android Xamarin.Andriod
  6. Xamarin • Founded in May 2011 • Xamarin has a

    perpetual license to all Mono IP: Copyrights, patents and trademarks • Focused on mobile app development
  7. Bringing .NET to Android Android Kernel Mono Runtime .NET APIs

    Apps Android Bindings Dalvik Runtime/ART android.* java.* MCW ACW
  8. Black Box C# in Xamarin + Visual Studio iPhone native

    (C# and XIB) Android native (C# and AXML) Windows Store (C# and XAML) Native apps and cross-platform UI (C# and Xamarin.Forms) Cross-platform with C#
  9. Xamarin.iOS does full ahead-of-time (AOT) compilation to produce an ARM

    binary suitable for Apple’s App Store Xamarin.Android takes advantage of just-in-time (JIT) compilation on the Android device Native cross-platform apps with Xamarin Native compilation, native performance
  10. C# unique approach powered by .NET and Xamarin The best

    of both worlds (UX & TCO) Great native apps delivered to the user’s choice of device Development agility, with Visual Studio to move at mobile speed
  11. Maximizing code reuse across platforms Views How to display information

    View models What information to display Flow of interaction Models Data objects Business logic Etc. Model View Model View Device-specific Portable code References Databinds Implemented in PCL or shared project
  12. Sharing code One of the main reasons to use Xamarin

    is the possibility of sharing a significant portion of your code across all your supported platforms
  13. Sharable Code Xamarin applications are native and therefore will always

    include some platform-specific code 30% 70% iOS 14% 86% Android 15% 86% Windows Phone Platform Specific Cross Platform
  14. Where can I use shared code? Anytime you are writing

    code which does not depend on a specific platform feature, it is potentially sharable, particularly if it: • Talks to a web service • Parses a data format • Uses a database • Performs processing or logic Create shared classes + methods and then use them from your platform- specific code to maximize the shareable surface area
  15. Where can I use shared code? Data Access (Database) •

    SQLite support available for iOS, Android and Windows • Can also store in the cloud – Azure Mobile Services, Amazon, Dropbox, etc. Web Services • Use HttpClient for REST services Xamarin.* Libraries • Xamarin.Social • Xamarin.Auth • Xamarin.Mobile Open-Source, Cross-Platform APIs available from Github.com/Xamarin
  16. When is code not sharable? If the code you are

    writing depends on device or platform-specific APIs, or APIs not available in your project, then you will need to isolate it's use or provide some kind of abstraction to use it from your shared code • Access system information • Use files and folders on the device • Access personal information • Use external devices
  17. Xamarin Component Store Can also get reusable components from the

    Xamarin Component Store which is accessible through the Components folder in each project
  18. Available project types There are two project styles available for

    sharing code – which one you select has an impact on how and what kind of code is shared Shared Project Portable Class Library