Native iOS and Android Development with Xamarin

46
Create native iOS & Android apps with Visual Studio and Xamarin James Montemagno @JamesMontemagno

Transcript of Native iOS and Android Development with Xamarin

Page 1: Native iOS and Android Development with Xamarin

Create native iOS & Android apps with Visual Studio and Xamarin

James Montemagno@JamesMontemagno

Page 2: Native iOS and Android Development with Xamarin

Who’s this guy?James

Montemagno

Principal Program Manager – Xamarin, Microsoft

[email protected] motzcod.es @JamesMontemagno

Weekly development podcast

mergeconflict.fm

Page 3: Native iOS and Android Development with Xamarin

Microsoft – Your Complete Mobile Solution

Page 4: Native iOS and Android Development with Xamarin

What is native?

Page 5: Native iOS and Android Development with Xamarin
Page 6: Native iOS and Android Development with Xamarin

Architecting mobile apps

Page 7: Native iOS and Android Development with Xamarin

Silo approach

iOS WindowsAndroid

Objective-C

Xcode

C#

Visual Studio

Java

Android Studio

No shared code • Many languages and development environments • Multiple teams

Page 8: Native iOS and Android Development with Xamarin

Write once, run anywhere

Lua

Javascript

Actionscript

HTML+CSS

Limited native API access • Slow performance • Poor user experience

App

generator

Page 9: Native iOS and Android Development with Xamarin

iOS C# UI Windows C# UIAndroid C# UI

Shared C# logic

Xamarin’s unique approach

Shared C# codebase • 100% native API access • High performance

Page 10: Native iOS and Android Development with Xamarin

Code sharing stats

Mac

iOS

Android

Windows Phone

iCircuit Touch Draw

86%

14%

72%

28%

70%

30%

61%

39%

88%

12%

76%

24%

90%

10%

Page 11: Native iOS and Android Development with Xamarin

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

C#

Page 12: Native iOS and Android Development with Xamarin

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

C#

Page 13: Native iOS and Android Development with Xamarin

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

C#

Page 14: Native iOS and Android Development with Xamarin

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.

ARM

BINARY

Runs natively

.APPAOT

.NET

C#

Bindings

.APKCompile

and Link

.NET

C#

Bindings

IL

+

JIT

Runs natively

Page 15: Native iOS and Android Development with Xamarin

✓ Always up-to-date

Same-day support:

• iOS 5

• iOS 6

• iOS 7

• iOS 8

• iOS 9

• iOS 10

Full support for:

• Apple Watch

• Apple TV

• Android Wear

• Amazon Fire TV

• Google Glass

• and much more

Page 16: Native iOS and Android Development with Xamarin

Visual Studio Xamarin Studio

Page 17: Native iOS and Android Development with Xamarin

Anything you can do in Objective-C, Swift, or Java can be done in C# and Visual Studio with Xamarin

Page 18: Native iOS and Android Development with Xamarin

Xamarin Platform is included for free in Visual Studio

Including Community Edition

Page 19: Native iOS and Android Development with Xamarin

Get Xamarin Today

Xamarin.com/Download

Page 20: Native iOS and Android Development with Xamarin

Open Source – open.xamarin.com

Page 21: Native iOS and Android Development with Xamarin

App building time

Page 22: Native iOS and Android Development with Xamarin

Sharing Code

Page 23: Native iOS and Android Development with Xamarin

1 Assembly

Multiple Platforms

Including:

Xamarin.iOS and Xamarin.Android

Portable Class Libraries – Profile Based

Page 24: Native iOS and Android Development with Xamarin

Share with

ASP.NET Core

.NET Core

and More!

Portable Class Libraries - netstandard

Page 25: Native iOS and Android Development with Xamarin

Shared Projects

Page 26: Native iOS and Android Development with Xamarin

NuGet

Page 27: Native iOS and Android Development with Xamarin

Simplifying Development

Page 28: Native iOS and Android Development with Xamarin

Shared C# Logic

What about this stuff?

Page 29: Native iOS and Android Development with Xamarin

Platform Specific Code

What if we didn’t have to write this code?

What if we could access it from shared code?

UI+APIs UI + APIsUI + APIs

Battery

GPS

Lights

Notifications

Settings

Text To Speech

Battery

GPS

Lights

Notifications

Settings

Text To Speech

Battery

GPS

Lights

Notifications

Settings

Text To Speech

Page 30: Native iOS and Android Development with Xamarin

TextToSpeech

Speak(“Hello World”);

AVSpeechSynthesizer SpeechSynthesizer

A Better API

Page 31: Native iOS and Android Development with Xamarin

Plugins for Xamarin

Common API

Xamarin.com/plugins

Page 32: Native iOS and Android Development with Xamarin

Plugin Time

Page 33: Native iOS and Android Development with Xamarin

Build native UIs for iOS, Android, and Windows

from a single, shared C# codebase.

Meet Xamarin.Forms

Page 34: Native iOS and Android Development with Xamarin

Xamarin + Xamarin.Forms

Traditional Xamarin approach With Xamarin.Forms:

More code-sharing, all native

iOS C# UI Windows C# UIAndroid C# UI

Shared C# Logic Shared C# Logic

Xamarin.Forms

Page 35: Native iOS and Android Development with Xamarin

What’s included

✓ 40+ Pages, layouts, and controls

(Build from code behind or XAML)

✓ Two-way data binding

✓ Navigation

✓ Animation API

✓ Dependency Service

✓ Messaging Center

Shared C# Logic

Shared UI Code

Page 36: Native iOS and Android Development with Xamarin

Pages

Stack Absolute Relative Grid ContentView ScrollView Frame

Content MasterDetail Navigation Tabbed Carousel

Layouts

Page 37: Native iOS and Android Development with Xamarin

ActivityIndicator BoxView Button DatePicker Editor

Entry Image Label ListView Map

OpenGLView Picker ProgressBar SearchBar Slider

Stepper TableView TimePicker WebView EntryCell

ImageCell SwitchCell TextCell ViewCell

Controls

Page 38: Native iOS and Android Development with Xamarin

Xamarin.Forms ecosystem

Page 39: Native iOS and Android Development with Xamarin

Native UI from shared code<?xml version="1.0" encoding="UTF-8"?>

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

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

x:Class="MyApp.MainPage">

<TabbedPage.Children>

<ContentPage Title="Profile" Icon="Profile.png">

<StackLayout Spacing="20" Padding="20"

VerticalOptions="Center">

<Entry Placeholder="Username"

Text="{Binding Username}"/>

<Entry Placeholder="Password"

Text="{Binding Password}"

IsPassword="true"/>

<Button Text="Login" TextColor="White"

BackgroundColor="#77D065"

Command="{Binding LoginCommand}"/>

</StackLayout>

</ContentPage>

<ContentPage Title="Settings" Icon="Settings.png">

<!-- Settings -->

</ContentPage>

</TabbedPage.Children>

</TabbedPage>

Page 40: Native iOS and Android Development with Xamarin

App building time

Page 41: Native iOS and Android Development with Xamarin

Integration & Delivery

Page 42: Native iOS and Android Development with Xamarin

Test

Page 43: Native iOS and Android Development with Xamarin

Build

Page 44: Native iOS and Android Development with Xamarin

Distribute & Monitor

Page 45: Native iOS and Android Development with Xamarin

Microsoft & Xamarin: Your Complete Mobile Solution

Develop Test Build Distribute Monitor

Page 46: Native iOS and Android Development with Xamarin

Thank You!

James

Montemagno

Principal Program Manager – Xamarin, Microsoft

[email protected] motzcod.es @JamesMontemagno

Weekly development podcast

mergeconflict.fm

Q&A