Your SlideShare is downloading. ×

Cross-Platform Mobile mit C#

966

Published on

Für Mobilgeräte gibt es unterschiedliche Ansätze, dieses Ziel zu erreichen. Im Rahmen dieses Vortrags wird der spannende Cross-Compile-Ansatz von Xamarin vorgestellt, der es ermöglicht, eine …

Für Mobilgeräte gibt es unterschiedliche Ansätze, dieses Ziel zu erreichen. Im Rahmen dieses Vortrags wird der spannende Cross-Compile-Ansatz von Xamarin vorgestellt, der es ermöglicht, eine gemeinsame Codebasis für die wichtigsten Plattformen zu pflegen und trotzdem native Oberflächen zu verwenden. Mit Hilfe des MvvmCross-Frameworks soll während des Vortrags in Visual Studio eine App erstellt werden, die Code Sharing bis einschließlich ViewModel ermöglicht und trotzdem native Oberflächen für Android und iOS umsetzt.
Präsentation auf der http://www.developer-week.de/ 2014

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
966
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Cross-platform mobile with C#
  • 2. © Zühlke 2014 Native Cross- compiled Hybrid Web Mobile development space Best usability? Manageable cost?
  • 3. What is Xamarin?
  • 4. © Zühlke 2014 What is Xamarin? • Cross-compiler based on Mono • Platforms – iOS – Android – Mac OS X • Development environment • Partnership with Microsoft Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 5. © Zühlke 2014 Why Xamarin? • Cross-platform – Shared code base – One modern language (C#) for all platforms • Native – Performance – User interface – API • Xamarin Studio (Mac, Windows) or Visual Studio (Windows) • Re-using code and know-how • Very good documentation Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 6. © Zühlke 2014 Cross-compiling • Compiling from C# (or F#) to native, platform- independent code • (Almost) complete functionality of .NET 4.5 • Package size increases by integrating parts of the framework • Xamarin Scanner http://scan.xamarin.com Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 7. © Zühlke 2014 Xamarin.iOS (formerly MonoTouch) • Ahead-of-time compile directly to ARM assembly code • No dynamic code generation – System.Reflection.Emit is missing – No Dynamic Language Runtime July 16 2014Cross-platform mobile with C# | Kerry W. Lothrop .NET C# AOT iOS-API .app ARM binary runs natively
  • 8. © Zühlke 2014 Xamarin.Android (formerly Mono for Android) • IL (Intermediate Language) and Mono runtime are deployed onto the device • Just-in-time compiler • Mono runtime runs parallel to Dalvik VM July 16 2014Cross-platform mobile with C# | Kerry W. Lothrop .NET C# Android-API .apk IL + JIT runs natively compile link
  • 9. Using native libraries Bindings for iOS and Android
  • 10. © Zühlke 2014 Bindings iOS • Tool: Objective Sharpie • Rework often necessary Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 .h [BaseType(typeof(NSObject))] interface MyClass { // Method [Export("draw:atColumn:andRow:")] void Draw(string text, int column, int row); // Property [Export("menuVisible")] bool MenuVisible { [Bind("isMenuVisible")] get; set; } } .cs
  • 11. © Zühlke 2014 Bindings Android • Insert *.jar • C# is automatically generated (JNI) • Transformationen may need to be amended Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 <metadata> <attr path="/api/package[@name='com.nostra13.universalimageloader.cache.memory.impl'] /class[@name='FIFOLimitedMemoryCache'] /method[@name='removeNext']" name="managedReturn"> Java.Lang.Object </attr> <attr path="/api/package[@name='com.nostra13.universalimageloader.core.imageaware'] /class[@name='ImageViewAware'] /method[@name='getWrappedView']" name="managedReturn"> Android.Views.View </attr> </metadata>
  • 12. © Zühlke 2014 Development environment Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 MacBook Windows 8 (VM)  Visual Studio 2013  ReSharper  Xamarin (iOS & Android) OS X  Xcode (SDK, simulators)  Xamarin.iOS  Xamarin Build Host
  • 13. Code Sharing
  • 14. © Zühlke 2014 Code Sharing Portable Class Libraries • Sharing at binary level • Limited functionality Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 15. © Zühlke 2014 Code Sharing Shared Projects • Sharing at code level • Compiler directives possible (#if) Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 16. Architecture
  • 17. © Zühlke 2014 Architecture MVC Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 View Model Controller
  • 18. © Zühlke 2014 View Architecture MVVM Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 View Android Model ViewModel platform- independent data binding View iOS View Windows Phone
  • 19. MvvmCross
  • 20. © Zühlke 2014 MvvmCross Project • Open source MVVM framework • Data binding • Dependency injection • Localization • Navigation • Portable Class Libraries • Plugins • NuGet • NinjaCoder • Stuart Lodge Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 21. © Zühlke 2014 MvvmCross Platforms Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 22. © Zühlke 2014 MvvmCross Extendability Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 interface IMvxPhoneCallTask { void MakePhoneCall( string name, string number); } View Android Model ViewModel View iOS View Windows Phone Windows Phone service Android service iOS service
  • 23. © Zühlke 2014 MvvmCross Plugins Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014
  • 24. Demonstration
  • 25. User Interface
  • 26. © Zühlke 2014 User Interface Xamarin.Forms Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 • Code sharing for UI Code • XAML • Native user interfaces • Mixing of Xamarin.Forms and plattform-specific views is possible <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ButtonXaml.ButtonXamlPage"> <Button Text="Tap for click count!" Clicked="OnButtonClicked" /> </ContentPage>
  • 27. Demonstration
  • 28. Summary
  • 29. © Zühlke 2014 Native Cross- compiled Hybrid Web Mobile development space Best usability? Manageable cost?
  • 30. © Zühlke 2014 Summary Cross-platform mobile with C# | Kerry W. Lothrop July 16 2014 • Cross-platform for all relevant devices without JavaScript • Native performance und possibilities • Reach more platforms with known existing tools • Each platform-specific UI technologie still needs to be learned. • Licensing cost can pay off even when targeting only one platform.
  • 31. Please share the slides if you liked them… Let‘s connect on LinkedIn Follow me on Twitter My profile on Xing

×