The document discusses Xamarin, a platform for building native iOS and Android apps using C#. Key points include:
- Xamarin allows building fully native mobile apps that share C# code using Xamarin.iOS and Xamarin.Android
- Xamarin 2.0 introduces Xamarin Studio IDE, support for C# 5 features like async/await, and a component store
- The document demos building an iOS and Android app with Xamarin and using async/await to simplify asynchronous code
2. Agenda
• About Xamarin
• Xamarin 2.0
• v.Now
C# 5 - async await
iOS UI Designer
iOS 7
Google Play Services for Android
Test Cloud
3. About Xamarin
• Apps are native, performance is native
• Entire platform SDK available to your code:
- iOS: StoreKit, EventKit, iCloud, etc
- Android: Play Services, Compatibility Library, etc
• Share C# across Xamarin, Windows & WinPhone apps
• Leverage platform-specific libraries:
iOS: Objective-C
Android: Java
user experience
performance
features
4. About Xamarin
• Mono
C# + .NET implementation for Linux
started in 2001/released 2004
• MonoTouch (for iOS) - 2009
• Mono for Android - 2011
• MonoDevelop IDE
• MonoMac open source project
iPhoneOS 3.0, pre-iPad
Android 2.3 Gingerbread
C# 1.0
5. About Xamarin
• Mono
C# + .NET implementation for Linux
started in 2001/released 2004
• MonoTouch (for iOS) - 2009
• Mono for Android - 2011
• MonoDevelop IDE
• MonoMac open source project
Mono 3.2
.NET 4.5
C# 5
iOS 7
Android 4.3 Jelly Bean
6. Xamarin 2.0
• Xamarin Studio
• Xamarin.iOS
Visual Studio
• Xamarin.Android
• Component Store
• Free Starter Edition
http://xamarin.com/guide/
http://blog.xamarin.com/announcing-xamarin-2.0/
7. How Does it Work?
Windows
C#
Xaml
C#
Network,
Storage,
Business
Logic
UI
wire
-‐up
logic
run/me
pla2orm
.NET
UI
your
code
8. How Does it Work?
Mono
.NET
RunBme
Windows
PhoneAndroid iOS WindowsMac
Shared
Code
(C#)
.NET
XamlAndroid
Xml Storyboards XIB
Xamarin.Android Xamarin.iOS Xamarin.Mac
C# C# C# C#
Xaml
C#
H7pClient
&
WebServices
SQLite.NET
&
database
IO
more...
UI
wire
-‐up
logic
run/me
pla2orm
UIUIUIUIUI
your
code
9. Mac OS X WindowsWindows
IDE
iOS
Android
Mac
Windows/Phone
Xamarin Development Environments
Xamarin
Business
Edition+
Mac
+
10. Mac OS XWindows
Visual Studio Xamarin Build Host
Xamarin.iOS for
Visual Studio plug-in
Build Host configuration
iOS Projects
iOS Property Pages
iOS build, deploy, debug
iOS Output panes
Device iOS Simulator
Apple iOS SDK
Xcode
Interface Builder
Compiler
Keychain Certifications
Provisioning Profiles
Network
access
iOS apps
in Visual
Studio?!
27. What is a Portable Class Library?
Subset of .NET that
is supported across
the set of target
platforms.
Starting with
File > New App
gives you platform-
specific code, eg.
Windows Store
28. What is a Portable Class Library?
Subset of .NET that
is supported across
the set of target
platforms.
Some Microso!
platforms (eg.
Windows Phone) are
more restricted than
Xamarin.
29. What is a Portable Class Library?
Subset of .NET that
is supported across
the set of target
platforms.
Some Microso!
platforms (eg.
Windows Phone) are
more restricted than
Xamarin.
but no dynamic (AOT)
30. What is a Portable Class Library?
Profile1
NetForWSA, Net4,
SL4, WP7, XBox360
31. What is a Portable Class Library?
Profile2
NetForWSA, Net4,
SL4, WP7
32. What is a Portable Class Library?
Profile104
NetForWSA, Net45,
SL4, WP75
33. PCL Example
Tasky Portable XML
An abstract implementation
of a data storage class, with
implementation for each
platform
Profile 158
34. PCL Example
The Portable Class Library is compiled in a
way that is sharable.
We create a Provider for each platform
37. Mobile Apps
• Need responsive user interfaces
• App features are o!en dependent on:
network access
database functionality or I/O
complex processing on mobile CPUs
stuff that takes some time
• You want to run these on a different thread to keep the UI
responsive... they should be ASYNCHRONOUS!
Fast!
Long running tasks!
Threads!
All
41. Old-style callbacks
• Spaghetti code:
Callbacks are the new “GOTO”
Control flow jumps around in ways that are difficult to read
& understand from the source
Error handling is difficult to implement, required in many
different places
Changes in the chain can have unintended consequences
http://tirania.org/blog/archive/2013/Aug-15.html
42. 1) Download Html string
2) Download Jpeg image
3) Save to Photo Album
5) Error Handling
4) Return Html length
Comparison
Async-ified
6) InvokeOnMainThread
43. 1) Download Html string
2) Download Jpeg image
3) Save to Photo Album
5) Error Handling
4) Return Html length
Comparison
6) InvokeOnMainThread
one place
not required
Async-ified
44. Comparison
1) Download Html string
2) Download Jpeg image
3) Save to Photo Album
5) Error Handling
4) Return Html length
6) InvokeOnMainThread
old new!
52. Recap
• Build iOS & Android apps in C# with .NET
Latest language features
• Use Xamarin Studio or Visual Studio
• Apps are native, with native performance
• Share C# code
• Latest C# 5 features
• Component Store
http://components.xamarin.com
• Test Cloud
http://testcloud.xamarin.com