Slide 1

Slide 1 text

Introduction to Xamarin 2.0 Miracle Open World 2013 2nd May 2013

Slide 2

Slide 2 text

Chris Hardy • .NET Contractor • Work with Xamarin • Wrote some books • First spoke about MonoTouch in January 2010 • http://twitter.com/chrisntr

Slide 3

Slide 3 text

MOW 2012 • Cross-platform with Xamarin • Linking code files • Portable Class Libraries

Slide 4

Slide 4 text

Xamarin 2.0

Slide 5

Slide 5 text

• C# and .NET for Android, iOS and Mac • Full native APIs – no compromise • Share code across Android, iOS, Mac, Windows Phone, Windows RT, Windows • Only platform that allows sharing code across these platforms while keeping native performance and UX What is Xamarin?

Slide 6

Slide 6 text

DEMO

Slide 7

Slide 7 text

• New Pricing - An edition for every developer • New Names - Xamarin.iOS, Xamarin.Android, Xamarin.Mac • Developer Center • Massively revamped documentation website • World class tutorials and guides What’s New in 2.0?

Slide 8

Slide 8 text

New Pricing

Slide 9

Slide 9 text

• Free Starter Edition • 32kb of user IL, can’t link native code • Indie Edition • Unrestricted size and native linking • Business Edition • Visual Studio, WCF, email support • Enterprise • App kickoff, priority support, free components • Trial Xamarin Editions

Slide 10

Slide 10 text

• Xamarin Studio The best IDE for mobile development • iOS for Visual Studio Develop iOS apps from VS on Windows • Component Store Drop-in components to build apps faster What’s New in 2.0?

Slide 11

Slide 11 text

Xamarin Studio

Slide 12

Slide 12 text

Xamarin Studio • Streamlined development experience • Responsive, beautiful user interface • Unified global search

Slide 13

Slide 13 text

Xamarin Studio • Fast, smooth C# code navigation, completion and refactoring • Git and subversion integration • Powerful debugger • Available on Windows and Mac

Slide 14

Slide 14 text

iOS for Visual Studio

Slide 15

Slide 15 text

iOS for Visual Studio • You asked for it, we delivered! • Write, build, deploy and debug iOS apps from Visual Studio • Take advantage of existing skills and extensions, for example TFS and ReSharper • Develop for iOS, Android, Windows Phone from a single solution

Slide 16

Slide 16 text

iOS for Visual Studio • Connects to Mac over network • Seamlessly transfers compiled C# to Mac for native build, sign • Launch and debug on simulator or device

Slide 17

Slide 17 text

DEMO

Slide 18

Slide 18 text

Component Store

Slide 19

Slide 19 text

Component Store • Paid and free components • Add Components to your app directly from within XS or VS • Submit your own!

Slide 20

Slide 20 text

DEMO

Slide 21

Slide 21 text

Automatically test your app on 100s of real devices in the cloud.

Slide 22

Slide 22 text

Test Cloud

Slide 23

Slide 23 text

Calabash

Slide 24

Slide 24 text

LessPainful Karl Krukow Jonas Maturana Larsen

Slide 25

Slide 25 text

In Beta Today Sign up for the beta at xamarin.com/test-cloud

Slide 26

Slide 26 text

Questions?

Slide 27

Slide 27 text

Xamarin 2.0 Part 2

Slide 28

Slide 28 text

Xamarin Evolve 2013 • C# 5.0 / async - await • F# support • Test Cloud • iOS Designer

Slide 29

Slide 29 text

Today • C# 5.0 / async - await • iOS Designer • C# 5.0 / async - await • F# support • Test Cloud • iOS Designer

Slide 30

Slide 30 text

Callbacks Are Today’s goto Statement 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 void  Refresh  () {        DownloadTweets  (OnTweetsDownloaded); } void  OnTweetsDownloaded  (Tweet  []  tweets) {        if  (tweets  ==  null)  {                ShowError  ("Error  downloading");        }  else  {                AddTweetsToScreen  (tweets);                DownloadAttachments  (tweets);        } } void  DownloadAttachments  (Tweet  []  tweets) {        foreach  (var  tweet  in  tweets)  {                  var  tweetUI  =  CreateTweetView();                if  (tweet.HasAvatar)  {                        Download  (tweet.AvatarUrl,  avatar  =>  {                                if  (avatar  ==  null)                                        return;                                InvokeOnMainThread  (()  =>  {                                        tweetUI.Avatar  =  avatar;                                });                        });                }                if  (tweet.HasImageAttachment)  {                        Download  (tweet.ImageUrl,  img  =>  {                                if  (img  ==  null)                                        return;                                InvokeOnMainThread  (()  =>  {                                        tweetUI.ImgAttachment  =  img;                                });                        });                }                if  (tweet.HasGeolocation)  {                        GeoLocation.ReverseLookup  (tweet.Location,  location  =>  {                                if  (location  ==  null)                                        return;                                InvokeOnMainThread  (()  =>  {                                        tweetUI.DisplayedLocation  =  location;                                });                        });                }        } }

Slide 31

Slide 31 text

C# 5.0 Async

Slide 32

Slide 32 text

C# 5.0 Async async  Task  RefreshAsync() {        var  tweets  =  await  DownloadTweetsAsync();        if  (tweets  ==  null)                return;        foreach  (var  tweet  in  tweets)  {                var  tweetView  =  CreateTweetView();                if  (tweet.HasAvatar)                        tweetView.Avatar  =  await  DownloadAsync  (tweet.AvatarUrl);                if  (tweet.HasImageAttachment)                        tweetView.ImgAttachment  =  await  DownloadAsync  (tweet.ImageUrl);                if  (tweet.HasGeolocation)                        tweetView.DisplayedLocation  =  await  GeoLocation.ReverseLookupAsync   (tweet.Location);        } }

Slide 33

Slide 33 text

Async in C# • New major feature of C# 5.0 Makes asynchronous programming a first- class citizen in C# Important part of C# – as significant as LINQ • New async modifier keyword introduced • Methods, lambda expressions, and anonymous methods can be asynchronous • New contextual keyword await introduced

Slide 34

Slide 34 text

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 Calculating a Price public  async  Task  CalculatePriceAsync  (Item[]  items) { using  (var  cmd  =  CreateSqlCommand   (Calculations.TotalPrice,  items))  { using  (var  reader  =  await  cmd.ExecuteReaderAsync  ())  { int  price  =  ReadPrice  (reader); return  price; } } } public  override  void  ViewDidLoad  () { button.TouchDown  +=  async  (sender,  e)  =>  { var  price  =  await  CalculatePriceAsync  (items); priceLabel.Text  =  price.ToString  (); }; }

Slide 35

Slide 35 text

DEMO

Slide 36

Slide 36 text

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Exception Handling with Await public  override  void  ViewDidLoad  () { button.TouchDown  +=  async  (sender,  e)  =>  { try  { button.Enabled  =  false; var  price  =  await  CalculatePriceAsync  (items); priceLabel.Text  =  price.ToString  (); }  catch  (Exception  ex)  { //  Handles  price  calculation  error priceLabel.Text  =  "Calculation  failed"; Debug.Print  (ex.ToString  ());  //  Simple  exception   logging }  finally  { button.Enabled  =  true; } };

Slide 37

Slide 37 text

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 Exception Throwing public  async  Task  CalculatePriceAsync  (Item[]  items) { if  (items  ==  null)  { //  Throw  before  suspension throw  new  ArgumentNullException  ("items"); } ... var  price  =  await  CalculatePriceAsync  (items); if  (price  <  0)  { //  Throw  after  suspension throw  new  ArgumentException  ("Invalid  items"); } ... }

Slide 38

Slide 38 text

Get Your Hands on Async • Async is available today Xamarin.iOS Beta release Xamarin.Android Beta release Xamarin Studio async support • Give us feedback on our new async API Forums Bugzilla

Slide 39

Slide 39 text

iOS Designer

Slide 40

Slide 40 text

DEMO

Slide 41

Slide 41 text

Xamarin.Mac

Slide 42

Slide 42 text

2.6 Billion Devices

Slide 43

Slide 43 text

Mac OS X The world’s most advanced desktop operating system C#

Slide 44

Slide 44 text

It’s all about sharing code Shared C# Code Xamarin.Mobile Business Logic Cloud Access Database Access Desktop Desktop Mobile Mobile Mobile Windows iOS Windows Phone Android Mac

Slide 45

Slide 45 text

TouchDraw runs on iPad, Android, and Mac, achieving over 70% code reuse across the platforms. 39% 61% TouchDraw for iPad 24% 76% TouchDraw for Mac 28% 72% TouchDraw for Android Shared Code Platform Specific

Slide 46

Slide 46 text

Xamarin.Mac at a glance • Write native Mac applications in C# • Access Mac OS X APIs for rich integration • Leverage the full power of C# and .NET • Integrated with the Xamarin experience • Deploy directly to the Mac AppStore

Slide 47

Slide 47 text

Xamarin.Mac at a glance Xamarin.Mac Frameworks Xamarin Tools and SDK • Binder • Bundler • Linker • Packager Mono Runtime .NET Base Class Libraries System Libraries Darwin OS Cocoa Frameworks Xcode (UI designer) Xamarin Studio IDE

Slide 48

Slide 48 text

How does Xamarin.Mac work? • OS X APIs are projected into C# 1:1 mapping for full platform coverage • 80% are Objective-C Full object system is mapped Subclassing and overriding supported • 20% are C Exposed as C# structs/classes/methods No support for subclassing or overriding

Slide 49

Slide 49 text

DEMO

Slide 50

Slide 50 text

Xamarin makes for Happy Devices Learn more: xamarin.com docs.xamarin.com Chris Hardy @chrisntr [email protected]