Mobile Cross-Platform App Development in C# with Xamarin

1,367 views
1,147 views

Published on

Building native applications across multiple platforms is hard. iOS requires knowledge of Xcode, the iOS SDK and Objective-C or Swift. Android requires Eclipse (or Android Studio), the Android SDK and Java. The Windows 10 Universal Windows Platform requires Visual Studio, C# and the WinRT SDK. Are we really expected to learn all of this? You can take the HTML5 & Cordova route, but not all apps should be built using a hybrid approach. If you want to create a truly competitive app with a premium experience, you’ll need to go native. Fortunately, there is a way you can share a lot of your code across mobile platforms and do so using the C# language you already know and love. Xamarin is a powerful toolset that allows developers to write native Android and iOS apps using C#, thanks to the Mono framework – an Open Source project that brings the C# language and .NET to other platforms. This session explores how you can build cross-platform applications for iOS, Android, and Windows using C#. You’ll learn how to get started with a sample cross-platform solution, which tools you can use, how to design a proper user interface for each platform and how to structure your projects for maximum code reuse. We’ll also look at how you can share UI code with Xamarin.Forms. Native mobile development doesn’t have to be so hard. Come learn how your .NET skills can be transformed for true cross-platform development.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,367
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
53
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Mobile Cross-Platform App Development in C# with Xamarin

  1. 1. Nick Landry Microsoft Senior Technical Evangelist nick.landry@microsoft.com Blog: AgeofMobility.com @ActiveNick Building Mobile Cross-Platform Apps for iOS, Android & Windows Devices with C# (and Xamarin & Visual Studio)
  2. 2. 1. 2. 3. 4. 5. 6. 7. 8. Agenda
  3. 3. Audience poll…
  4. 4. Architecting Mobile Apps
  5. 5. Silo Approach: Build the Same Apps Multiple Times
  6. 6. The Siloed approach: Build native apps multiple times Multiple teams and multiple code bases are expensive and slow + + - ✗
  7. 7. Write Once, Run Anywhere Approach Lowest Common Denominator Browser Fragmentation • App Generation. • Web Browser in a Native Wrapper + Platform APIs.
  8. 8. The write-once-run-anywhere approach HTML Hybrid scenarios (Semi-native apps) like PhoneGap (i.e. Cordova) ✗
  9. 9. Xamarin’s Unique Approach Shared C# codebase • 100% native API access • High performance iOS C# UI Windows C# UIAndroid C# UI Shared C# Mobile C# Server Linux/Mono CoreCLRAzure Shared C# Client/Server
  10. 10. C# and Xamarin’s unique approach The best of all worlds
  11. 11. How Xamarin Works
  12. 12. How Does Xamarin Run C# on iOS or Android?
  13. 13. Xamarin History Over a Decade of Enterprise Production Use 2000 Ximian Founded 2001 Mono Started 2003 Ximian Acquired by Novell 2009 First iOS product (now Xamarin.iOS) launches 2011 Xamarin Founded First Release of Xamarin.Android 2012 First release of Xamarin.Mac Launch Partner Program 2013 Xamarin 2.0 Component Store Evolve 2013 Xamarin Test Cloud Microsoft Partnership Reach 200,000 Developer Mark 500,000+ Developers 100+ Partners 100+ Components
  14. 14.        Xamarin in 2015       
  15. 15. Windows APIs Microsoft.Phone Microsoft.Networking Windows.Storage Windows.Foundation Microsoft.Devices System.Data System.Windows System.Numerics System.Core System.ServiceModel System.Net System System.IO System.Linq System.Xml
  16. 16. iOS – 100% API Coverage MapKit UIKit iBeacon CoreGraphics CoreMotion System.Data System.Windows System.Numerics System.Core System.ServiceModel System.Net System System.IO System.Linq System.Xml
  17. 17. Android – 100% API Coverage Text-to-speech ActionBar Printing Framework Renderscript NFC System.Data System.Windows System.Numerics System.Core System.ServiceModel System.Net System System.IO System.Linq System.Xml
  18. 18. Demo: Building a Basic Native Cross-Platform App in C#
  19. 19. All 3 characteristics are required for a truly native app Xamarin is native in all 3 ways Native User Interface Apps are built with standard, native user interface controls for easy and familiar interactions Apps have access to the full spectrum of functionality exposed by the underlying platform and device Apps leverage platform-specific hardware acceleration, and are compiled as native binaries, not interpreted at runtime. High-fidelity API Access Native Performance
  20. 20. Xamarin exposes 100% of the native APIs for iOS, Android and Windows
  21. 21. Anything you can do in Objective-C or Java can be done in C# with Xamarin using Visual Studio
  22. 22. Native Performance  Xamarin.iOS does full Ahead Of Time (AOT) compilation to produce an ARM binary for Apple’s App Store.  Xamarin.Android takes advantage of Just In Time (JIT) compilation on the Android device.
  23. 23. Always Up-to-Date Full support for: Google Glass, Android Wear, Amazon Fire TV
  24. 24. Xamarin Products and Tools
  25. 25. Xamarin: How much? Starter Edition (free) Indie Edition ($299) Business Edition ($999) Enterprise Edition ($1899) Integration with Visual Studio in Business Edition & above
  26. 26. • • • • • Xamarin: How much?
  27. 27. Xamarin.Mac Xamarin Studio Xamarin Test Cloud Component Store Xamarin.iOS Xamarin.Android Xamarin for Visual Studio .NET Mobility Scanner
  28. 28. Development Environment Xamarin Studio PC or Mac Visual Studio Plugin VS 2010/2012/2013
  29. 29.     Xamarin Studio
  30. 30.          Visual Studio Integration
  31. 31.         Visual Studio Integration
  32. 32.        Android Designer
  33. 33.      iOS Designer
  34. 34. Xamarin + Xamarin.Forms With Xamarin.Forms: more code-sharing, native controls Traditional Xamarin approach Shared UI Code
  35. 35.    Xamarin + Xamarin.Forms Shared UI Code
  36. 36.        What’s Included in Xamarin.Forms Shared UI Code
  37. 37. How Xamarin.Forms works Shared App Logic in C# At runtime, each Xamarin.Forms page and its controls are mapped to platform-specific native user interface elements iOS C# UI Android C# UI Shared App Logic Windows C# UI Use a single API to generate native, platform- specific user interfaces
  38. 38. Xamarin.Forms: Build Native User Interfaces Using Shared Code Shared App Logic in C# Xamarin.Forms comes with over 40 common controls, pages and layouts to make app UI creation fast and easy Even basic animations are supported Xamarin.Forms is Fully Extensible: • Subclass included controls and customize behavior • Define and add your own controls, layouts, pages and cells • Expose your own platform-specific controls in Xamarin.Forms pages
  39. 39. Demo: Sharing UI Code with Xamarin.Forms
  40. 40. Use Decide Screen-by-Screen Xamarin.Forms is great for forms-based screens. You can mix Xamarin.Forms with the full power of Xamarin.iOS and Xamarin.Android in the same app for complete control over your app’s look and feel. Xamarin.Forms: Mix-and-Match Screen-by-Screen, Element-by-Element Call Platform APIs via Shared Services Need platform-specifc functionality within a Xamarin.Forms page, such as querying the accelerometer? We’ve included services that quickly and easily abstract platform-specific API calls to keep you writing as much shared code as possible. Embed Custom Views Anywhere Not only are Xamarin.Forms pages mixable with custom screens, you can embed custom views built directly against Xamarin.iOS and Xamarin.Android into Xamarin.Forms pages.
  41. 41. Sharing Code
  42. 42. Shared Projects
  43. 43. NuGet
  44. 44. Portable Class Libraries     
  45. 45.           Choosing a Code Sharing Option
  46. 46. Demo: Sharing Code PCLs
  47. 47. Component Store • Over 150 curated mobile components • Android • iOS • Windows • Free & Paid • Full IDE Integration • Xamarin Studio • Visual Studio
  48. 48. Automatically test your app on hundreds of mobile devices
  49. 49. Native Dev: Platform Tools or Xamarin? Platform Tools (Windows, iOS, Android) • Default native method to build apps • Free development tools & SDKs • Requires learning at least one language & SDK per platform (C#, Java, Objective-C) • Design, develop & maintain completely separate apps for each platform • More learning resources available • Books, web sites, blogs, training, StackOverflow, videos, larger community, etc. • Yet, iOS developers are (kinda) starting all over with Swift Xamarin / Mono • Reuse existing C# skills & source code (but you have to know C#) • Need to buy an additional tool: extra cost • Need to learn new tools & techniques • Still need to learn the specifics of each platform SDK, app architecture & lifecycle • Fewer third-party libraries available • Built-in GUI designer for iOS and Android • Xamarin.Forms provides native shared Uis, but there is no XAML designer (yet) • Vendor lock-in / dependency
  50. 50. Mobile Strategy Considerations Audience • General Consumer Market • Niche Consumer Market • Enterprise Users • BYOD Objectives • Marketing “Checklist” Apps • Brand “Reach” Apps • Weekend Warrior Apps • Apps for Profit • Mobile Revolution Apps Other Considerations • Mobile Population Coverage Target & Desired Reach • Expertise • Resources • Timeframe
  51. 51.         Summary
  52. 52.   github.com/ActiveNick/MyWeatherNUI  github.com/ActiveNick/MyWeather  github.com/ActiveNick/BingTranslateDemo  github.com/ActiveNick/HelloWeather  github.com/ActiveNick/AzureChatrforWindows   github.com/jamesmontemagno/MyStocks.Forms  github.com/jamesmontemagno/MyExpenses-Sync Session Demos
  53. 53.   http://channel9.msdn.com/events/Build/2015/3-770  http://aka.ms/ch9xam2015-1  http://aka.ms/ch9xam2015-2  http://aka.ms/ch9xam2015-3  http://aka.ms/ch9xam2015-4  http://channel9.msdn.com/Search?term=xamarin#ch9Search&lang-en=en Xamarin Videos for Developers
  54. 54.   http://xamarin.com/download   http://docs.xamarin.com   http://evolve.Xamarin.com   http://xamarin.com/university   http://blog.xamarin.com   http://motzcod.es   http://weblogs.asp.net/wallym   http://www.gregshackles.com Xamarin Resources
  55. 55. Xamarin Developer Certifications: Be part of an Elite Developer Community Students have the option to take a certification test and become Xamarin certified. Xamarin skills are increasingly in demand – certifications let the market know you represent top talent.
  56. 56. Online Microsoft training delivered by experts to help technologists continually learn Hundreds of courses for developers, IT Pros, students, entrepreneurs and enthusiasts 11 different languages More than 3M students registered Build your own Learning Plan All free! Cross-Platform Development with Xamarin & Visual Studio aka.ms/MVAxamarin http://www.microsoftvirtualacademy.com
  57. 57. Recommended Xamarin Books http://aka.ms/Xs5v48 Xamarin Mobile Application Development for Android (Mark Reynolds) http://aka.ms/Ndl0jn iOS Development with Xamarin Cookbook (Dimitris Tavlikos) http://aka.ms/S8akz1 Xamarin Cross-Platform Application Development (Jonathan Peppers) http://aka.ms/Sl5aj9
  58. 58. Recommended iOS Books http://iosfordotnetdevs.com Programming iOS 7, 4th Edition (Neuburg, O’Reilly) http://amzn.to/1el9Z7L iOS Programming: The Big Nerd Ranch Guide 4th Edition (Conway, Hillegass, Keur) http://amzn.to/1dIM999 Objective-C Programming: The Big Nerd Ranch Guide 2nd Edition (Hillegass, Ward) http://amzn.to/1kHJQaB
  59. 59. Recommended Android Books Android Programming: The Big Nerd Ranch Guide (Bill Phillips, Brian Hardy) http://amzn.to/1k7jeuK Programming Android: Java Programming for the New Generation of Mobile Devices (Mednieks, Dornin, et al.) http://amzn.to/1bdHA4W
  60. 60. Thank You! Slides are posted on Slideshare. Demos are on GitHub. Slideshare: www.slideshare.net/ActiveNick Blog: www.AgeofMobility.com Twitter: @ActiveNick Mobile Apps: www.bigbaldapps.com LinkedIn: www.linkedin.com/in/activenick GitHub: github.com/ActiveNick Email: nick.landry@microsoft.com

×