Share
Embed
Hajan Selmani: Building cross platform mobile apps with Xamarin
Realm
April 25, 2016
Transcript
28 slides
-
App Builders Switzerland | @appbuilders_ch Building cross-platform mobile apps with
Xamarin Hajan Selmani Founder & CEO of HASELT Founder of Hyper Arrow Microsoft MVP -
• Cross-platform (native) apps development, now and in the future?
• Understanding Xamarin • Why using it? Real reasons and benefits • Visual Studio, .NET and C# • iOS/Android/Windows Apps with Visual Studio & C# • Tooling, plugins, support and current state • Showcase Session objectives -
Xamarin Deliver native iOS, Android and Windows apps using existing
skills, teams, and code. -
Why Cross-platform with Xamarin and .NET? One programming language to
rule them all Use C# and Visual Studio to build native apps for any device, any platform now and in the future C# (pronounced as see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. High Quality Apps with Shared code-base Support customers on every device, everywhere with shared codebase using one language Avoid platform disparity. Do not fix the same bug three times Full access and control of the platforms Use the best features available on each platform Have full access to all platforms Lower Development Costs -
How does it works? C# language Allows you to use
a familiar syntax and sophisticated features like Generics, Linq and the Parallel Task Library. Mono .NET framework Provides a cross-platform implementation of the extensive features in Microsoft’s .NET framework. Compiler Depending on the platform, produces a native app (eg. iOS) or an integrated .NET application and runtime (eg. Android). The compiler also performs many optimizations for mobile deployment such as linking away un-used code. IDE Tools The Xamarin Studio IDE and the Xamarin plug-in for Visual Studio allow you to create, build and deploy Xamarin projects. -
Under the hood Compilation iOS – C# is ahead-of-time (AOT)
compiled to ARM assembly language. The .NET framework is included, with unused classes being stripped out during linking to reduce the application size. Apple does not allow runtime code generation on iOS, so some language features are not available (see Xamarin.iOS Limitations ). Android – C# is compiled to IL and packaged with MonoVM + JIT’ing. Unused classes in the framework are stripped out during linking. The application runs side-by-side with Java/ART (Android runtime) and interacts with the native types via JNI (see Xamarin.Android Limitations ). Windows Phone – C# is compiled to IL and executed by the built-in runtime, and does not require Xamarin tools. Designing Windows Phone applications following Xamarin’s guidance makes it simpler to re-use the code on iOS and Android. -
Under the hood Platform SDK Access iOS – Xamarin.iOS exposes
Apple’s CocoaTouch SDK frameworks as namespaces that you can reference from C#. For example the UIKit framework that contains all the user interface controls can be included with a simple using MonoTouch.UIKit; statement. Android – Xamarin.Android exposes Google’s Android SDK as namespaces, so you can reference any part of the supported SDK with a using statement, such as using Android.Views; to access the user interface controls. Windows Phone – Windows Phone is not part of the Xamarin platform. When building apps for Windows Phone in C#, the SDK is implicitly available to your application, including Silverlight/XAML controls for the user interface. -
Windows APIs Microsoft.Phone Microsoft.Networking Windows.Storag e Windows.Foundation Microsoft.Device s System.Data
System.Windows System.Numeric s System.Core System.ServiceMod el System.Net System System.IO System.Linq System.Xml -
iOS – 100% API Coverage MapKit UIKit iBeacon CoreGraphics CoreMotion
System.Data System.Windows System.Numeric s System.Core System.ServiceMod el System.Net System System.IO System.Linq System.Xml -
Android – 100% API Coverage Text-to-speech ActionBar Printing Framework Renderscript
NFC System.Data System.Windows System.Numeric s System.Core System.ServiceMod el System.Net System System.IO System.Linq System.Xml -
Xamarin’s Cross-platform approach Shared C# codebase • 100% native API
access • High performance Windows-specific C# Android-specific C# iOS-specific C# Shared C# Logic J ava Android Studio in Android codebase iOS codebase Objective-C X Code in C# Visual Studio in Windows codebase -
Sharing Code - Strategies Shared Projects Put shared code in
a “Shared Project” Reference the shared project from Android, iOS, Windows, Web And the source code from the shared project is included. Very flexible, can use partial classes, very simple, full API access Portable Class Libraries For when you are designing code to be consumed by others Easier to consume by third parties Limited API access -
Plugins for Xamarin Common Mobile API xamarin.com/plugins Speech Camera Settings
Connectivity SMS Location Platform Native APIs -
Xamarin.Forms Windows-specific C# Android-specific C# iOS-specific C# Shared C# Logic
J ava Android Studio in Objective-C X Code in C# Visual Studio in Shared Xamarin.Forms UI -
Inspector IDE support to inspect live applications Monitor your application
live Execute C# code against a running application Make changes, explore your application Powered by Roslyn’s C# Cross Platform Supports Android, iOS, Mac and Windows -
Workbooks Bringing Interactive C# to the next level Learn by
experimentation Workbooks are live documents They contain Markdown text With embedded C# code The code executes on demand And re-executes any code after you make changes -
App Builders Switzerland | @appbuilders_ch THANK YOU Building cross-platform mobile
apps with Xamarin Hajan Selmani CEO & Founder of HASELT Microsoft MVP