Introduction to Xamarin - Confoo 2015

59
Native Cross-Platform Mobile Development with Xamarin Freelance Solutions Architect www.guybarrette.com Guy Barrette

Transcript of Introduction to Xamarin - Confoo 2015

Page 1: Introduction to Xamarin - Confoo 2015

Native Cross-Platform

Mobile Development

with Xamarin

Freelance Solutions Architect

www.guybarrette.com

Guy Barrette

Page 2: Introduction to Xamarin - Confoo 2015

Guy Barrette

Page 3: Introduction to Xamarin - Confoo 2015

Mobile

Development

Approaches

Page 4: Introduction to Xamarin - Confoo 2015

Silo Approach

Build Apps Multiple Times

• Multiple Teams

• Multiple Code Bases

• Different toolsets

Page 5: Introduction to Xamarin - Confoo 2015

Write Once, Run Anywhere: Web Approach

• Build a mobile version of an existing

Web site

• No apps to deploy to the stores

Page 6: Introduction to Xamarin - Confoo 2015

Write Once, Run Anywhere: Hybrid Approach

• Use PhoneGap/Cordova with HTML5

• Basically, a native app with a Web viewer displaying HTML5 pages

• Native look is simulated with CSS

• Apps are packaged as native apps

Page 7: Introduction to Xamarin - Confoo 2015

Xamarin

Approach

Page 8: Introduction to Xamarin - Confoo 2015

Xamarin’s Unique Approach

• Native User Interface

• Native Performance

• Shared code across

platforms

• C# & .NET Framework

• Full API Coverage

Page 9: Introduction to Xamarin - Confoo 2015

With Xamarin.Forms:

more code-sharing, native controlsTraditional Xamarin approach

Shared UI Code

Xamarin.Forms Unique Approach

Page 10: Introduction to Xamarin - Confoo 2015

Xamawhat???

Page 11: Introduction to Xamarin - Confoo 2015

First

release of

Xamarin.Mac

Launch

Partner

Program

200,000

Developers

Xamarin

Founded

First release of

Xamarin.Android

Xamarin.iOS

launches (originally

known as

MonoTouch)

Ximian

Founded

Over a Decade of Enterprise Production Use

2001 2003 2009 2011 2012 2013

Mono

Launches

Ximian Acquired

by Novell

Xamarin 2.0

Component Store

Xamarin Test Cloud

Evolve 2013

Microsoft Partnership

500,000

Developers

100+ Partners

100+ Components

2014

//

Xamarin 3

2000

SAP Partnership

Fire TV Support

Salesforce partnership

Visionary in Gartner

Magic Quadrant

Google Glass Support

Visual Studio Partner

of the Year

Android Wear Support

Xamarin Evolve 2014

800,000

Developers

200+ Partners

200+ Components

Page 12: Introduction to Xamarin - Confoo 2015

How

Xamarin

Works

Page 13: Introduction to Xamarin - Confoo 2015

Write Everything in C#

Page 14: Introduction to Xamarin - Confoo 2015

.NET + iOS APIs | 100% Coverage

Page 15: Introduction to Xamarin - Confoo 2015

.NET Android APIs | 100% Coverage

Page 16: Introduction to Xamarin - Confoo 2015

.NET + Windows APIs

Page 17: Introduction to Xamarin - Confoo 2015

Anything you can do in Objective-C, Swift,

or Java can be done in C# with Xamarin

Page 18: Introduction to Xamarin - Confoo 2015

Share code across all platforms

Page 19: Introduction to Xamarin - Confoo 2015

60% to 90% code reuse

Page 20: Introduction to Xamarin - Confoo 2015

Xamarin.iOS does full Ahead Of

Time (AOT) compilation to produce

an ARM binary for Apple’s App

Store.

Native Performance

Xamarin.Android takes advantage

of Just In Time (JIT) compilation

on the Android device.

Page 21: Introduction to Xamarin - Confoo 2015

• 1 Assembly

• Multiple Platforms

• Including:

• Xamarin.Android

• Xamarin.iOS

Portable Class Libraries

Page 22: Introduction to Xamarin - Confoo 2015

Distribute Everywhere

A Xamarin app can be distributed everywhere

Page 23: Introduction to Xamarin - Confoo 2015

Xamarin Studio

PC or MacVisual Studio Plugin

VS 2010 and Higher

Development Environment

Page 24: Introduction to Xamarin - Confoo 2015

Cost - Software

Cost per dev and per device

platform:• iOS

• Android

• Discount for startups and MSDN

subscribers

Page 25: Introduction to Xamarin - Confoo 2015

Cost - Hardware

• Android• Development can be done on Windows or Mac

• iOS• A Mac is required

• Development can be done on a Windows machine

but compilation MUST be done on a Mac

• Compilation can be done on a networked Mac

Page 26: Introduction to Xamarin - Confoo 2015

Cost - Hardware

• Emulators are OK for

development

• But always test on physical

devices

Page 27: Introduction to Xamarin - Confoo 2015

Visual Studio Integration

A single solution:

• iOS

• Android

• Windows Phone

• Windows Store

Leverage the entire

Microsoft ecosystem:• ReSharper

• Team Foundation Server

• Your favorite code coverage

and profiling tools

Page 28: Introduction to Xamarin - Confoo 2015

Xamarin Studio

• Optimized for cross-platform

mobile development

• Explore native APIs with code

completion

• World class Android and iOS

designers

• Powerful debugging on

simulator or device

Page 29: Introduction to Xamarin - Confoo 2015

Android Designer

• Android designer

• Available in:

• Xamarin Studio

• Visual Studio

• Create UI with drag & drop

simplicity

• Target multiple screen sizes,

resolutions and Android

versions

• Layouts saved in standard

Android XML files

Page 30: Introduction to Xamarin - Confoo 2015

iOS Designer

• iOS Designer available in

Xamarin Studio and Visual

Studio

• Follows familiar Visual Studio

designer idioms

• Supports all UIKit elements

• Edit custom and 3rd party

components

• Live preview of changes to

properties

Page 31: Introduction to Xamarin - Confoo 2015

Xamarin.Forms

Page 32: Introduction to Xamarin - Confoo 2015

With Xamarin.Forms:

more code-sharing, native controlsTraditional Xamarin approach

Shared UI Code

Xamarin + Xamarin.Forms

Page 33: Introduction to Xamarin - Confoo 2015

40+ Pages, Layouts, and Controls

Build from code behind or XAML

Two-way Data Binding

Navigation

Animation API

Dependency Service

Messaging Center

Shared UI Code

What’s Included

Page 34: Introduction to Xamarin - Confoo 2015

Use a single API to generate native, platform-

specific user interfaces

At runtime, each Xamarin.Forms page and its

controls are mapped to platform-specific

native user interface elements

Xamarin.Forms Example

Page 35: Introduction to Xamarin - Confoo 2015

C# or XAML, No Designer Yetvar red = new Label

{

Text = "Stop",

BackgroundColor = Color.Red,

Font = Font.SystemFontOfSize (20),

WidthRequest = 100

};

var yellow = new Label

{

Text = "Slow down",

BackgroundColor = Color.Yellow,

Font = Font.SystemFontOfSize (20),

WidthRequest = 100

};

var green = new Label

{

Text = "Go",

BackgroundColor = Color.Green,

Font = Font.SystemFontOfSize (20),

WidthRequest = 200

};

Content = new StackLayout

{

Spacing = 10,

VerticalOptions = LayoutOptions.End,

Orientation = StackOrientation.Horizontal,

HorizontalOptions = LayoutOptions.Start,

Children = { red, yellow, green }

};

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

x:Class="HelloXamarinFormsWorldXaml.StackLayoutExample3"

Padding="20">

<StackLayout Spacing="10"

VerticalOptions="End"

Orientation="Horizontal"

HorizontalOptions="Start">

<Label Text="Stop"

BackgroundColor="Red"

Font="20"

WidthRequest="100" />

<Label Text="Slow down"

BackgroundColor="Yellow"

Font="20"

WidthRequest="100" />

<Label Text="Go"

BackgroundColor="Green"

Font="20"

WidthRequest="200" />

</StackLayout>

</ContentPage>

Page 36: Introduction to Xamarin - Confoo 2015

Xamarin.Forms Controls

Page 37: Introduction to Xamarin - Confoo 2015

Xamarin.Forms = Version 1

Page 38: Introduction to Xamarin - Confoo 2015

General rule with V1:

For simpler business apps

Page 39: Introduction to Xamarin - Confoo 2015

Demo

Page 40: Introduction to Xamarin - Confoo 2015

Conclusion

Page 41: Introduction to Xamarin - Confoo 2015

Xamarin benefits

• Xamarin enables developers to reach all major mobile platforms!

– Native User Interface

– Native Performance

– Shared Code Across Platforms

– C# & .NET Framework

Page 42: Introduction to Xamarin - Confoo 2015
Page 43: Introduction to Xamarin - Confoo 2015

It depends

Page 44: Introduction to Xamarin - Confoo 2015

Is your team more familiar

with HTML/JS or C#?

Page 45: Introduction to Xamarin - Confoo 2015

You still need to understand the

intricacies of each platform

Page 46: Introduction to Xamarin - Confoo 2015

Thank you

Page 47: Introduction to Xamarin - Confoo 2015
Page 48: Introduction to Xamarin - Confoo 2015

Additional Material

Page 49: Introduction to Xamarin - Confoo 2015

Tools

Page 50: Introduction to Xamarin - Confoo 2015

Always Up-to-Date

Track record of offering

same-day support:iOS 5, iOS 6, iOS 7, iOS 7.1, iOS 8

Full support for:• Google Glass

• Android Wear

• Amazon Fire TV

• More!

Page 51: Introduction to Xamarin - Confoo 2015

• Xamarin Studio

• VS coming soon

• Supports:

– iOS

– Android

– Mac

– Xamarin.Forms

• developer.xamarin.com/guides/cross-platform/sketches/

Live Coding Environment

Sketches

Page 52: Introduction to Xamarin - Confoo 2015

Xamarin Profiler Preview

• Analyze and Polish your C# Mobile Apps

• iOS, Android, and Xamarin.Forms

• Windows or Mac

• Xamarin.com/profiler

Page 53: Introduction to Xamarin - Confoo 2015

Xamarin Component Store

Build Apps Faster

• Add high quality pre-built

app components directly

from Visual Studio and

Xamarin Studio

• Beautiful cross-platform UI

controls, cloud services and

enterprise backend

integrations are just a few

clicks away

Page 54: Introduction to Xamarin - Confoo 2015

Xamarin Android Player

High Speed Android Emulator

• Mac or PC

• Runs side-by-side Windows

Phone Emulator

Free for Xamarin Subscribers:

• Xamarin.com/Android-Player

Page 55: Introduction to Xamarin - Confoo 2015

.NET Mobility Scanner

How mobile is your .NET?

• Go to: http://scan.xamarin.com

• Scan .exe or .dll to determine compatibility

• Generates full report:

Page 56: Introduction to Xamarin - Confoo 2015

Real-time monitoring. Track crashes and exceptions to

understand what is happening with live users.

Page 57: Introduction to Xamarin - Confoo 2015

Automatically test your app on thousands

of real devices in the cloud.

Page 58: Introduction to Xamarin - Confoo 2015

• IBM MobileFirst SDK for Xamarin

• IBM MobileFirst Add-Ons for

Xamarin Studio and Visual Studio

• xamarin.com/ibm

IBM Partnership

Page 59: Introduction to Xamarin - Confoo 2015

Microsoft and Xamarin Partner Globally

With Xamarin, developers combine all of the

productivity benefits of C#, Visual Studio 2013

and Windows Azure with the flexibility to

quickly build for multiple device targets.”

S. Somasegar, Corporate Vice President, Microsoft