1
Mobile Development in .NET mit Xamarin
2
Mobile Web (Hybrid) Apps
Vorteil: • Weniger Aufwand• Multi-Plattform• Web-Technologien
Nachteil: UX• Performance• UI Design• Gerätefunktionen
3
Plattform abstrahieren
4
Entwicklung pro Plattform
5
Xamarin Ansatz
6
Native Mobile Apps mit Xamarin
1. Bestehendes .NET Know-How
2. Mächtige Plattform und Tools(Linq, Xml, Events/Delegates, Parallel Programming, Visual Studio/TFS, …)
3. Shared Code zwischen Plattformen
7
Benötigtes Know-How
.NET
8
Xamarin.iOSC#
9
Xamarin.Android
twitterListView.setOnItemClickListener (new OnItemClickListener () {public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
Intent tweetDetails = new Intent (TwitterScreen.this, TweetDetailsScreen.class);tweetDetails.putExtra ("TweetID", TwitterFeed[position].ID);startActivity (tweetDetails);
}};
twitterListView.ItemClick += (s, e) => {var tweetDetails = new Intent (this, typeof (TweetDetailsScreen));tweetDetails.PutExtra ("TweetID", TwitterFeed[e.Position].ID);StartActivity (tweetDetails);
};
C#
10
Entwicklungsumgebung
OS Mac OSX Windows
UI Designer Android, iOS
Build Android, iOS
Debug Android (Device und ARM/x86 Emulator)iOS (Device und Emulator auf Mac)
11
Kompilierung und Ausführung
Android APK
Android/Linux KernelIL Code für plattform-
spezifische ProfileSolution mit
Projekten
iOS APP
Android APK
Shared Code(C#,F#,VB.NET)
Mono CLR für iOS(Monotouch)
Mono CLR für Android
(Monodroid)
Multi-PlatformProfil Assembly
Dalvik
Android.*Java.*
IL+JIT
AOT ARM Binary
iOS App (C#,F#)
Android App(C#,F#)
Xamarin.iOSProfil Assembly
Xamarin.AndroidProfil Assembly
iOS/Cocoa Touch
iOS APP
ARMBinary
12
Architektur
Portable Class Library
ViewModel
Entities
Repository/DAL
Business Logic
CloudServiceAccessAndroid App
iOS App
View Controllers
Storyboards/Segues
Table Views
Foundation/UIKit
Activities
Intents
ListViews, Adapters
Android SDK
13
DEMO
14
Architektur
NuGet PackagePure/Advanced PCL
Android App
iOS App
View Controllers
Storyboards/Segues
Table Views
Foundation/UIKit
Activities
Intents
ListViews, Adapters
Android SDK
Android Class LibraryIPlatformDependentImplementation
iOS Class LibraryIPlatformDependentImplementation
Portable Class Library
ViewModel
Entities
Repository/DAL
Business Logic
IPlatformDependent
CloudServiceAccess
15
Portierbarer Code (Anteil in %)
72%
61%
86%
70%
46%
44%
53%
53%
16
Portabilität erhöhen
Portable Class Libraries für Xamarin• HTTPClient• Json.Net• MvvMCross• RestSharp• CouchBase• MailKit/MimeKit• …
17
Portabilität erhöhen
Xamarin Components/Plugins• Battery Status• Compass• Barcode Scanner• Device Info• File System• Notifications• Messaging• Push Notifications• Text To Speech• Contacts• Leds• Microsoft Band• …
https://github.com/xamarin/XamarinComponents
18
Xamarin.Forms
Eine UI Definition für alle 3 Plattformenin XAML (DataBinding)Verwendet native UI ControlsMischung möglich
19
DEMO
20
ALM Tool Chain und TFS Integration
• VCS nach Wahl• Xamarin Studio hat keinen TFS- VCS Support
• Builds• TFS 2015 Buildsystem• MacOS/Windows Agents• Tasks zum Builden
• Issues/Board• Keine Änderung
21
Debugging
Voller Funktionsumfang:Breakpoints, Watches, Callstack, …
Unterstützung für:Android (Hardware & Emulator)iOS (Hardware & Emulator über Build Host)
22
Testing
•Manuelles Testen•Unit Tests möglich
• Xamarin Test Cloud• ~2000 verschiedene Geräte zum Testen• Nicht in Lizenz enthalten
23
Zusätzliche Tools von Xamarin
• Xamarin Android Player• Remote iOS Simulator• Xamarin.Forms Previewer (alpha)•Workbooks
24
Xamarin Lizenzierung und Kosten
Lizenzierung bei Visual Studio Lizenz dabei auch bei Community Edition
Mac Hardware für Xamarin.iOS benötigt
25
Xamarin Nachteile
StabilitätMehraufwand bei der Architektur, damit der Code portable bleibt
26
Fazit
Mobile Apps dringen in alle Bereiche vor Android und iOS als dominante Plattformen
Schneller Einstieg für .NET/C# Entwickler Einarbeitung in Android/iOS SDK erforderlich
Mächtige Werkzeuge und Plattformen (.NET/VS) X-Plattform Code Sharing (50-80%) Hohe Popularität in der .NET Community (Libraries!)
27
Popularität
28
Fragen?
Recommended