cross-platform mobile development using visual studio and xamarin

46
Cross-Platform Mobile Development using Visual Studio and Xamarin

Upload: shravan-kumar-kasagoni

Post on 13-Jan-2017

286 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Cross-Platform Mobile Development using Visual Studio and Xamarin

Cross-Platform Mobile Development using Visual Studio and Xamarin

Page 2: Cross-Platform Mobile Development using Visual Studio and Xamarin

Shravan Kumar KasagoniSenior Developer - RealPageMicrosoft MVP – VSDTMicrosoft User Group Hyderabad @techieshravan

Page 3: Cross-Platform Mobile Development using Visual Studio and Xamarin

Agenda

Mobile development challengesNative Android, iOS and Windows applicationsCreate mobile experiencesFaster development cycles

Page 4: Cross-Platform Mobile Development using Visual Studio and Xamarin

Mobile represents the single largest technology innovation of all time

Page 5: Cross-Platform Mobile Development using Visual Studio and Xamarin

Smartphone adoption is happening

10XFaster than the PC boom of the 80s

2XFaster than the Internet boom of the 90s

3XFaster than the recent social networking explosion

Page 6: Cross-Platform Mobile Development using Visual Studio and Xamarin

Extend to any device

Take advantage of cloud scale and economics

Business agility

Core-businessApplications

Mobile apps are part of a broader modernization

Mobile

Cloud

Agile

Page 7: Cross-Platform Mobile Development using Visual Studio and Xamarin

Approaches for device development

Native Hybrid

Tool maturity

Device optimized experience

Updatability

Portability across devices

Page 8: Cross-Platform Mobile Development using Visual Studio and Xamarin

Write-once-run-anywhere approachHybrid apps. Presentation written in HTML/CSS and behavior written in JavaScript/TypeScriptHighest code reuse ratio at UI expensePerformance depends on the containerApache Cordova/Ionic

Write-once-run-anywhere

box

CSS • HTML • TypeScript • JavaScript • Ionic • …

Page 9: Cross-Platform Mobile Development using Visual Studio and Xamarin

Hybrid app build-in support with Cordova.Full developer workflow for coding, debugging, and instrumenting device hybrid apps.Visual Studio productivity for Android, iOS, and Windows devices.

Web and hybrid apps

+ Integrated hybrid app support

Black Box

CSS | HTMLJavaScript | TypeScript

Powerful IDE for HTML5 / CSS3.Highly interactive JavaScript-based apps.Suited for LOB browser-based apps.

Web development with Visual Studio

Page 10: Cross-Platform Mobile Development using Visual Studio and Xamarin

Native mobile apps are better…

- Performance - Richness of UI

Page 11: Cross-Platform Mobile Development using Visual Studio and Xamarin

Silo’ed approach

Building native apps multiple times meansClient development is completely different for each device typeOnly the Services (server-side) can be reused, with certain differences when consuming themTCO grows exponentially

Objective-C, SwiftXCode

JavaEclipse

C#, JS, C++Visual Studio

Page 12: Cross-Platform Mobile Development using Visual Studio and Xamarin

Using the platform’s native tools (Siloed approaches are long term problems)

Xcode ADT Visual Studio

…Multiple code bases and skills, fragmented tools, different teams

End user experienc

e

Better productivity andglobal developer

experience

✗ Great apps, but…

Building native apps multiple times when targeting multiple

platforms!

…very expensive,not sustainable…

+

+

-

Page 13: Cross-Platform Mobile Development using Visual Studio and Xamarin

C# and Xamarin to the rescue!

Page 14: Cross-Platform Mobile Development using Visual Studio and Xamarin

How?

Page 15: Cross-Platform Mobile Development using Visual Studio and Xamarin

Mono Framework

Page 16: Cross-Platform Mobile Development using Visual Studio and Xamarin

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.

Page 17: Cross-Platform Mobile Development using Visual Studio and Xamarin

Bringing .NET to Linux

Windows Linux

Microsoft .NET

.NET Apps

Mono/.NET Core

.NET Apps

Page 18: Cross-Platform Mobile Development using Visual Studio and Xamarin

.NET on Android, iOS

Linux

Mono

iOS

Mono Touch

Android

Mono for Android

iOS

Xamarin.iOS

Android

Xamarin.Andriod

Page 19: Cross-Platform Mobile Development using Visual Studio and Xamarin

Xamarin• Founded in May 2011

• Xamarin has a perpetual license to all Mono IP: Copyrights, patents and trademarks

• Focused on mobile app development

Page 20: Cross-Platform Mobile Development using Visual Studio and Xamarin

Bringing .NET to Android

Android Kernel

Mono Runtime

.NET APIs

Apps

Android Bindings

Dalvik Runtime/ART

android.* java.*MCW

ACW

Page 21: Cross-Platform Mobile Development using Visual Studio and Xamarin

Bringing .NET to iOS

iOS

Mono Runtime

NO RUNTIMES ALLOWED

Page 22: Cross-Platform Mobile Development using Visual Studio and Xamarin

Bringing .NET to iOS

iOS

App

.NET APIS iOS Bindings

Application Code

Page 23: Cross-Platform Mobile Development using Visual Studio and Xamarin

Anything you can do in Objective-C, Swift, or Java; can be done in C#

Page 24: Cross-Platform Mobile Development using Visual Studio and Xamarin

Microsoft supports your choice

.NET Desktop apps Universal Windows apps

HTMLBrowser-based applications

Rich experiences Breadth of devices

Page 25: Cross-Platform Mobile Development using Visual Studio and Xamarin

Xamarin and Visual Studio

Page 26: Cross-Platform Mobile Development using Visual Studio and Xamarin

Black Box

Shared code across platforms

with C# and Portable Libraries

Native UI or shared user experiences

with Xamarin.Forms

C# in Xamarin+ Visual Studio 1iPhone native (C# and XIB)

2Android native (C# and AXML)

3Windows Store (C# and XAML)

4 Native apps and cross-platform UI (C# and Xamarin.Forms)

Cross-platform with C#

Page 27: Cross-Platform Mobile Development using Visual Studio and Xamarin

C# + XIB C# + AXML C# + XAMLiPhone Android Windows

Shared client app C# code

Xamarin provides native cross-platform for iOS and Android.Share app logic code across device platforms.Common cross-platforms UX with Xamarin.Forms.

Cross-platform mobile native apps for iOS, Android, and Windows devices with C#Cross-platform with

Xamarin

Full access to device features with 100% APIs exposed, everything you can do in xCode or ADT (Android Development Tools) you can do with C# and Xamarin.Highly flexibility and customization apps for each target device.Best UX and performance in devices.

Native apps in C#

Page 28: Cross-Platform Mobile Development using Visual Studio and Xamarin

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

Page 29: Cross-Platform Mobile Development using Visual Studio and Xamarin

C# unique approach powered by .NET and XamarinThe 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

End user experienc

e

Developer experienceBetter TCO and productivity

Page 30: Cross-Platform Mobile Development using Visual Studio and Xamarin

Create UI with drag and drop simplicity.Target multiple screen sizes, resolutions, and OS versions.Layouts saved in native resource formats.World’s best Android designer available in Visual Studio.Xamarin 3 designer in Visual Studio, for iOS.

UI design in Visual Studio

Xamarin designer for Android apps

Xamarin designer for iOS apps

Page 31: Cross-Platform Mobile Development using Visual Studio and Xamarin

WindowsAPIs

100%coveragewith .NET

Page 32: Cross-Platform Mobile Development using Visual Studio and Xamarin

iOSAPIs

100%coveragewith Xamarin

Page 33: Cross-Platform Mobile Development using Visual Studio and Xamarin

AndroidAPIs

100%coveragewith Xamarin

Page 34: Cross-Platform Mobile Development using Visual Studio and Xamarin

Maximizing code reuse across platforms

ViewsHow to display information

View modelsWhat information to displayFlow of interaction

ModelsData objectsBusiness logicEtc.

Model

View Model

View Device-specific

Portable codeReferences

Databinds

Implemented in PCL or shared project

Page 35: Cross-Platform Mobile Development using Visual Studio and Xamarin

Demo

Xamarin + C# + Visual Studio

Page 36: Cross-Platform Mobile Development using Visual Studio and Xamarin

Sharing code

Page 37: Cross-Platform Mobile Development using Visual Studio and Xamarin

Sharing codeOne of the main reasons to use Xamarin is the possibility of sharing a significant portion of your code across all your supported platforms

Page 38: Cross-Platform Mobile Development using Visual Studio and Xamarin

Sharable CodeXamarin applications arenative and therefore willalways include someplatform-specific code

30%

70%

iOS14%

86%

Android

15%

86%

Windows Phone

Platform Specific

Cross Platform

Page 39: Cross-Platform Mobile Development using Visual Studio and Xamarin

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

Page 40: Cross-Platform Mobile Development using Visual Studio and Xamarin

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.MobileOpen-Source, Cross-Platform APIs available from Github.com/Xamarin

Page 41: Cross-Platform Mobile Development using Visual Studio and Xamarin

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

Page 42: Cross-Platform Mobile Development using Visual Studio and Xamarin

Xamarin Component StoreCan also get reusable components from the Xamarin Component Store which is accessible through the Components folder in each project

Page 43: Cross-Platform Mobile Development using Visual Studio and Xamarin

Available project typesThere are two project styles available for sharing code – which one youselect has an impact on how and what kind of code is shared

Shared Project Portable Class Library

Page 44: Cross-Platform Mobile Development using Visual Studio and Xamarin

Demo

Shared Projects

Page 45: Cross-Platform Mobile Development using Visual Studio and Xamarin

Demo

Portable Class Library

Page 46: Cross-Platform Mobile Development using Visual Studio and Xamarin

Thank You