62
Ruben Vermeersch @rubenv Mobile with Mono

Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Ruben Vermeersch@rubenv

Mobile with Mono

Page 2: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support
Page 3: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Mobile apps on different platforms

State of the union

Page 4: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Three platforms,three technologies

Objective-CCocoa / UIKit

JavaAndroid SDK

C#WinRT

Page 5: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Building on all platforms

Fully native Hybrid Web

Loads of workNo reuse

No device APIsFeels wrong

Awesome Code reuse

Page 6: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

TodayLife improvement for developers!

Xamarin.iOS & Xamarin.Android

Page 7: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

TodayLife improvement for developers!

Page 8: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Brief history

Page 9: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Miguel De Icaza

Page 10: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Miguel De Icaza Evolution

Page 11: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

• Reimplementation of .NET

• Tons of platforms

• Linux, Mac, Windows, PS3, Xbox, Wii, iOS, Android, Z-Series

• 13 years in development

Page 12: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

"Let us make developer tools that are objects of desire"

Page 13: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Part 1

Page 14: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Xamarin{iOSAndroidMac

Page 15: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support
Page 16: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support
Page 17: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

What is Xamarin.iOS?

.NET bindings to iOS APIs

• Plain C libraries and frameworks

• CoreFoundation based frameworks

• Objective-C based frameworks

Page 18: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

What is it not?• Not a UI toolkit!

• Not a platform abstraction!

• As a user, no way to tell the difference from 100% native

Page 19: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

API bindings Xamarin Studio SDK

Bindings to the native APIs IDE project support Build tools

Mono Runtime Extensions to

bridge .NET and Objective-C

Xcode designer integration Packaging / Signing

iOS 4.0 and up Project templates Documentation

Page 20: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Some benefits• One binding, multiple languages (most important: C#, soon: F#)

• Reuse C# across platforms

• Strongly typed APIs

• Easy to explore

• Garbage collection everywhere

• Both Foundation and CoreFoundation objects

• Unlike ARC which is limited to NSObject

• Safe runtime, access to .NET class libraries and .NET ecosystem

Page 21: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Strongly typed APIs• Foundation/CoreFoundation are weakly typed

• Think C# 1.0 collections: ArrayList, Hashtable

• Mono exposes strong types:

UIView [] Views { get; set; }

vs.

(NSArray *) views;

Page 22: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Objective-C Sample

Page 23: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C# Version

Page 24: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C APIsCoreFoundation APIs

Page 25: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C APIsCoreFoundation APIs

Page 26: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C APIsAudioToolbox

Page 27: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C APIsAudioToolbox

Page 28: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Code completion

Page 29: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Code completion

Page 30: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Code completion

Page 31: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Debugging

Page 32: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Debugging

Page 33: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Design Philosophy• Expose a direct binding to native APIs

• Most of time 1:1 mapping

• Expose strong types, hide weak types

• Wrap "dictionary"-based APIs into strong types

• Maps Objective-C Delegate pattern to C# events

Page 34: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

More fun stuff

Page 35: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Beautiful async

Blocking the UI is the root of all evil user frustration

Page 36: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Beautiful asyncBlocking the UI is the root of all evil user frustration

void DownloadTweets ()! ! {! ! ! FetchUrl (tweetUrl, result => {! ! ! ! tweetDb.Populate (ParseJsonResult (result), () => {! ! ! ! ! View.ReloadData ();! ! ! ! });! ! ! });! ! }

Page 37: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

! ! void DownloadTweets ()! ! {! ! ! FetchUrl (tweetUrl, result => {! ! ! ! if (result == null)! ! ! ! ! View.InvokeOnMainThread (() => {! ! ! ! ! ! ShowError ("Could not download tweets");! ! ! ! ! });! ! ! ! tweetDb.Populate (ParseJsonResult (result), (error) => {! ! ! ! ! if (error) {! ! ! ! ! ! Tweet.UpdateLastRead (lastValidCode, errorPost => {! ! ! ! ! ! ! if (errorPost != null)! ! ! ! ! ! ! ! View.InvokeOnMainThread (() => {! ! ! ! ! ! ! ! ! ShowError ("Twitter is down");! ! ! ! ! ! ! ! });! ! ! ! ! ! });! ! ! ! ! } else {! ! ! ! ! ! View.InvokeOnMainThread (() => {! ! ! ! ! ! ! View.ReloadData ();! ! ! ! ! ! ! lastValidCode = currentCode;! ! ! ! ! ! });! ! ! ! ! }! ! ! ! });! ! ! });! ! }

Page 38: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

C# 5 Async! ! async void DownloadTweets ()! ! {! ! ! var tweets = await FetchUrl (tweetUrl);! ! ! if (tweets == null) {! ! ! ! ShowError ("Could not download tweets");! ! ! ! return;! ! ! }

! ! ! if (!await tweetDb.Populate (ParseJsonResult (result)) {! ! ! if (!await Tweet.UpdateLastRead (lastValidCode))! ! ! !ShowError ("Twitter is down");! ! ! } else {! ! ! ! View.ReloadData ();! ! ! }! ! }

Page 39: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Component Store

Page 40: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Component Store

Page 41: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Recipes

http://docs.xamarin.com/recipes

Page 42: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Visual Studio SupportiOS and Android!

Page 43: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

UI Designers

Page 44: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

In shortWhat the iOS developer story should have been

Page 45: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Part 2

Page 46: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support
Page 47: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Model

View

Controller

Page 48: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Model

View

Controller

Platform-specific

Reusable (up to a certain extent)

Page 49: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Model

View

ControllerPresenterViewModelWhatever

Platform-specific

Reusable (up to a certain extent)

Page 50: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

MVVMCross

https://github.com/slodge/MvvmCross

Page 51: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Native UI APIs Xamarin.iOS Xamarin.Android WinRT

C# Business Logic and Middleware(engine, core and 3rd party)

Runtime Mono .NET

OS iOS Android Win8

>2.6 billion devices!

Page 52: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Native UI APIs

Xamarin.iOS

Xamarin.Android WinRT Winforms,

WPFGtk# Xamarin.Mac

ASP.NET

C# Business Logic and Middleware(engine, core and 3rd party)

Runtime Mono .NET

OS iOS Android Win8 Windows(Old)

Linux(Mac /

Windows)OS X Server

Page 53: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Xamarin Test cloudiOS and Android

Real devices!Discovery mode

Page 54: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Some examples

Page 55: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

WestVlinderen

Page 56: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Axa

Page 57: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

• iOS

• Android

• WP7

Page 58: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

No free lunch

Page 59: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support
Page 60: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Take away

• Xamarin.iOS on its own will make your life as an iOS developer more enjoyable

• The mono/.Net ecosystem allows code reuse and more reusability in development without sucking

• Give it a try!

http://xamarin.com/

Page 61: Mobile with Mono€¦ · Mobile apps on different platforms State of the union. Three platforms, ... API bindings Xamarin Studio SDK Bindings to the native APIs IDE project support

Discuss!Questions? Demo?

Ruben [email protected]

@rubenv