Upload
dinhnguyet
View
245
Download
1
Embed Size (px)
Citation preview
Go Mobile with
C#, Visual Studio, and Xamarin
James MontemagnoPrincipal Program Manager - Xamarin,
Microsoft
Who’s this guy?James
Montemagno
Principal Program Manager – Xamarin, Microsoft
[email protected] motzcod.es @JamesMontemagno
Weekly development podcast
mergeconflict.fm
Xamarin: your complete mobile solution
Develop Test Build Distribute Monitor
What is native?
Architecting mobile apps
Silo approach
iOS WindowsAndroid
Objective-C
Xcode
C#
Visual Studio
Java
Android Studio
No shared code • Many languages and development environments • Multiple teams
Write once, run anywhere
Lua
Javascript
Actionscript
HTML+CSS
Limited native API access • Slow performance • Poor user experience
App
generator
iOS C# UI Windows C# UIAndroid C# UI
Shared C# logic
Xamarin’s unique approach
Shared C# codebase • 100% native API access • High performance
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%
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#
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#
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#
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
✓ Always up-to-date
Same-day support:
• iOS 5
• iOS 6
• iOS 7
• iOS 8
• iOS 9
Full support for:
• Apple Watch
• Apple TV
• Android Wear
• Amazon Fire TV
• Google Glass
• and much more
Visual Studio Xamarin Studio
Anything you can do in Objective-C, Swift, or Java can be done in C# and Visual Studio with Xamarin.
Xamarin is includedin Visual Studio
Open Source – open.xamarin.com
Sharing Code
1 Assembly
Multiple Platforms
Including:
Xamarin.iOS and Xamarin.Android
Portable Class Libraries
Shared Projects
NuGet
App building time
Shared C# Logic
What about this stuff?
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
TextToSpeech
Speak(“Hello World”);
AVSpeechSynthesizer SpeechSynthesizer
A Better API
Plugins for Xamarin
Common API
Xamarin.com/plugins
Plugin Time
Build native UIs for iOS, Android, and Windows
from a single, shared C# codebase.
Meet Xamarin.Forms
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
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
Pages
Stack Absolute Relative Grid ContentView ScrollView Frame
Content MasterDetail Navigation Tabbed Carousel
Layouts
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
Xamarin.Forms ecosystem
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>
App building time
Integration & Delivery
Test
Build
Distribute & Monitor
Xamarin: your complete mobile solution
Develop Test Build Distribute Monitor
Thank You! Q&A
James
Montemagno
Principal Program Manager – Xamarin, Microsoft
[email protected] motzcod.es @JamesMontemagno
Weekly development podcast
mergeconflict.fm