Introduction to Xamarin - Confoo 2015

Preview:

Citation preview

Native Cross-Platform

Mobile Development

with Xamarin

Freelance Solutions Architect

www.guybarrette.com

Guy Barrette

Guy Barrette

Mobile

Development

Approaches

Silo Approach

Build Apps Multiple Times

• Multiple Teams

• Multiple Code Bases

• Different toolsets

Write Once, Run Anywhere: Web Approach

• Build a mobile version of an existing

Web site

• No apps to deploy to the stores

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

Xamarin

Approach

Xamarin’s Unique Approach

• Native User Interface

• Native Performance

• Shared code across

platforms

• C# & .NET Framework

• Full API Coverage

With Xamarin.Forms:

more code-sharing, native controlsTraditional Xamarin approach

Shared UI Code

Xamarin.Forms Unique Approach

Xamawhat???

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

How

Xamarin

Works

Write Everything in C#

.NET + iOS APIs | 100% Coverage

.NET Android APIs | 100% Coverage

.NET + Windows APIs

Anything you can do in Objective-C, Swift,

or Java can be done in C# with Xamarin

Share code across all platforms

60% to 90% code reuse

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.

• 1 Assembly

• Multiple Platforms

• Including:

• Xamarin.Android

• Xamarin.iOS

Portable Class Libraries

Distribute Everywhere

A Xamarin app can be distributed everywhere

Xamarin Studio

PC or MacVisual Studio Plugin

VS 2010 and Higher

Development Environment

Cost - Software

Cost per dev and per device

platform:• iOS

• Android

• Discount for startups and MSDN

subscribers

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

Cost - Hardware

• Emulators are OK for

development

• But always test on physical

devices

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

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

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

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

Xamarin.Forms

With Xamarin.Forms:

more code-sharing, native controlsTraditional Xamarin approach

Shared UI Code

Xamarin + Xamarin.Forms

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

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

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>

Xamarin.Forms Controls

Xamarin.Forms = Version 1

General rule with V1:

For simpler business apps

Demo

Conclusion

Xamarin benefits

• Xamarin enables developers to reach all major mobile platforms!

– Native User Interface

– Native Performance

– Shared Code Across Platforms

– C# & .NET Framework

It depends

Is your team more familiar

with HTML/JS or C#?

You still need to understand the

intricacies of each platform

Thank you

Additional Material

Tools

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!

• Xamarin Studio

• VS coming soon

• Supports:

– iOS

– Android

– Mac

– Xamarin.Forms

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

Live Coding Environment

Sketches

Xamarin Profiler Preview

• Analyze and Polish your C# Mobile Apps

• iOS, Android, and Xamarin.Forms

• Windows or Mac

• Xamarin.com/profiler

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

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

.NET Mobility Scanner

How mobile is your .NET?

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

• Scan .exe or .dll to determine compatibility

• Generates full report:

Real-time monitoring. Track crashes and exceptions to

understand what is happening with live users.

Automatically test your app on thousands

of real devices in the cloud.

• IBM MobileFirst SDK for Xamarin

• IBM MobileFirst Add-Ons for

Xamarin Studio and Visual Studio

• xamarin.com/ibm

IBM Partnership

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