Building Cross-Platform
applications using Xamarin and C#
Open House – January 2014

Ofir Makmal - Senior Consultant
Email...
Agenda
Mobile Market Review
iOS vs Android vs Windows (PhoneStore)
JavaScript, CSS, HTML 5 alternative
Xamarin approach
Th...
Mobile Platforms

iOS

Android

• Storyboards
• Objective C
• Xcode

• XML-based UI
• Java
• Eclipse/Android
Studio/Intell...
Earlier, 4%
iOS 6, 22%

OS Versions
Windows
Phone
7.x, 30%

iOS 7, 74%

Froyo
(2.2), 1.60%
Windows
Phone
8, 70%

Honeycomb...
iOS Basic Concepts

Foundation/UIKit
View controllers
Storyboards and segues
Table views
Android Basic Concepts

Android SDK
Activities
Intents
ListViews and adapters
Windows Runtime Basic Concepts

.NET Framework
Pages
Navigation
ListViews and binding
Targeting all major platforms
Theoretically, can provide the best UX, but
Comes with a great cost
Acquire specialties with...
What's out there?
What Is PhoneGap All About?

What about performance, UX, Look&Feel?
Introducing Xamarin
Write C#. Run on 2.5 billion devices.
Xamarin
Founded in 2011 by Novell ex-employees
Based on the Mono project – launched on 2001
Brings the .NET Framework to L...
Why Xamarin?
Write in C#
Write in C#!!
100% platform API coverage
Same-day support for all new API’s
Average of 75% code s...
Boring, yet important
Officially partnered with Microsoft
MSDN special plans

Over 460,000 developers live, 20,000 paying
...
Demo
Xamarin stack
Where is the magic?
Xamarin.iOS - full
Ahead-of-Time (AOT)
compilation to produce
an ARM binary suitable
for Apple's App S...
Xamarin on iOS (monoTouch)
AOT – Ahead Of Time compilation (no JIT)
Support ARMv6, ARMv7, ARMv7s
Can use the LLVM optimizi...
Xamarin on Android (monoDroid)
Runs both Dalvik and CLR at the same time
Similar linker as to iOS – reduce the application...
Xamarin Application Architecture
User Interface Designer
Android
AXml editor
All standard android UI controls
Built-in – both Visual Studio and Xamarin Stu...
Code sharing ‘tactics’
File-Linking
Using symbolic links to shared files from different
projects
Generally used with condi...
Portable Class Library
Support various deployment targets
Windows 78 Desktop apps
Windows 8 Store Apps
Windows Phone 78
Xa...
Portable Class Library – cont.
Portable Class Library – cont.
Almost every package on NuGet comes with
PCL
HttpClient
Immutable Collections
SignalR
OData...
MvvmCross
By far the best and most robust Mvvm
framework
Supports:
Xamarin.iOS
Xamarin.Android
Windows Phone
Windows Store...
Demo
Visual Studio Integration
iOS application can be developed in Visual
Studio, but you will still need a Mac
For building th...
Visual Studio Integration – cont.
Android works within VS as any other C#
project
Simulator needs some tweaks for performa...
Xamarin Studio (monoDevelop)
Fully featured, modern IDE
Global type search
Code Navigation
Both Mac and Windows versions
M...
Demo
Xamarin.Mobile
Address book
using Xamarin.Contacts;
var contacts = new AddressBook ();

if (await book.RequestPermission()...
PushSharp
Server-side library for sending Push
Notifications
iOS (iPhone/iPad APNS)
Android (C2DM and GCM - Google Cloud
M...
Interoperability
Use native libraries as if they were written in C#
You can wrap a driver for any specific platform and
us...
Make your app Xamarin-friendly
Good separation between UI code and BL
E.g. Do not use BitmapImage on your BL

Whatever you...
Showcase
Bastion
3rd party components
There is a component for almost every need
Google Play Services
Windows Azure Mobile Services
Faceboo...
Scan your code for conformance
scan.xamarin.com
Demo
Licensing
Getting started with Xamarin
Scan your code for conformance:
scan.xamarin.com
Download:
Trial program – 30 days
MSDN Subsc...
Questions
Thank you!
If you can do it in Objective-C and Java,
you can do it in C# with Xamarin.
Ofir Makmal - Senior Consultant
Ema...
Upcoming SlideShare
Loading in …5
×

Xamarin Open House talk - Sela Group - Ofir Makmal

1,703 views
1,484 views

Published on

In a 3 hours talk, I have covered some pros and cons about going the native way, the HTML\JS\CSS hybrid way, and of course, Xamarin.

Most of the talk focused on Xamarin approach, gory implementation details, cross-platform architecture, code sharing ‘tactics’, MvvmCross, tips and more.

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

No Downloads
Views
Total views
1,703
On SlideShare
0
From Embeds
0
Number of Embeds
60
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Titanium – Cross-platform JS runtime and api – with generated components for native experiencePhoneGap/Cordoba – Cross-platform JS runtime and api - JS, CSS, HTML Hybrid applicationsSencha – JS, CSS, HTML application with no apiCorona – mostly focusing on games, using Lua scripting language
  • Ximian – Novell – Attachmate
  • Demo application – SDP\Tasky?
  • ThreeDemos, and short code structure review.Core:platform-specific abstractions, models, services, ViewModels, BL, IoC, Navigation service, cache, local DB, JSON/serialization, communication, loggingApplication Specific: Bindings, Animations, specific OS functionality
  • Xamarin Open House talk - Sela Group - Ofir Makmal

    1. 1. Building Cross-Platform applications using Xamarin and C# Open House – January 2014 Ofir Makmal - Senior Consultant Email: Ofirm@sela.co.il Blog: http://blogs.microsoft.co.il/ofirmakmal Twitter: @OfirMakmal LinkedIn: http://www.linkedin.com/in/ofirmakmal © Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
    2. 2. Agenda Mobile Market Review iOS vs Android vs Windows (PhoneStore) JavaScript, CSS, HTML 5 alternative Xamarin approach The magic behind Cross-Platform Application Architecture Code-Sharing ‘tactics’ Components store/open source components Tips, tricks and others caveats
    3. 3. Mobile Platforms iOS Android • Storyboards • Objective C • Xcode • XML-based UI • Java • Eclipse/Android Studio/IntelliJ IDEA Windows Phone/Windows 8 • XAML-based UI • C#, VB, C++, JavaScript • Visual Studio
    4. 4. Earlier, 4% iOS 6, 22% OS Versions Windows Phone 7.x, 30% iOS 7, 74% Froyo (2.2), 1.60% Windows Phone 8, 70% Honeycomb (3.x), 0.10% KitKat (4.4), 1.10% Gingerbread (2.3.x), 24.10% ICS (4.0.x), 18.60% JellyBean (4.14.3), 54.50%
    5. 5. iOS Basic Concepts Foundation/UIKit View controllers Storyboards and segues Table views
    6. 6. Android Basic Concepts Android SDK Activities Intents ListViews and adapters
    7. 7. Windows Runtime Basic Concepts .NET Framework Pages Navigation ListViews and binding
    8. 8. Targeting all major platforms Theoretically, can provide the best UX, but Comes with a great cost Acquire specialties with at list three different technologies No code sharing Every feature, bug, needed to be implemented several times
    9. 9. What's out there?
    10. 10. What Is PhoneGap All About? What about performance, UX, Look&Feel?
    11. 11. Introducing Xamarin Write C#. Run on 2.5 billion devices.
    12. 12. Xamarin Founded in 2011 by Novell ex-employees Based on the Mono project – launched on 2001 Brings the .NET Framework to Linux and OS X Stable, great performance, tooling, huge code base Xamarin took it to the next step: all major platforms – iOS, Android, Linux, OS X
    13. 13. Why Xamarin? Write in C# Write in C#!! 100% platform API coverage Same-day support for all new API’s Average of 75% code sharing! You can keep using Visual Studio And your favorite extensions or you can use the free Xamarin Studio All latest C# goodness – LINQ, asyncawait, TPL
    14. 14. Boring, yet important Officially partnered with Microsoft MSDN special plans Over 460,000 developers live, 20,000 paying customers, 120 consulting partners Used by more than 20% of Fortune 500 companies Great documentation and tutorials Very responsive community and forums Reuse your company’s current development investment
    15. 15. Demo
    16. 16. Xamarin stack
    17. 17. Where is the magic? Xamarin.iOS - full Ahead-of-Time (AOT) compilation to produce an ARM binary suitable for Apple's App Store. Xamarin.Android - takes advantage of Just In Time compilation right on the Android device
    18. 18. Xamarin on iOS (monoTouch) AOT – Ahead Of Time compilation (no JIT) Support ARMv6, ARMv7, ARMv7s Can use the LLVM optimizing compiler Uses mtouch Static analysis-based linker Only dependent components are being compiled and deployed Reduce the size of the application dramatically Can be disabled using flags (No Link, Link SDK Only) or manually using attributes From Apple perspective – Xamarin application is like any other native application on the AppStore
    19. 19. Xamarin on Android (monoDroid) Runs both Dalvik and CLR at the same time Similar linker as to iOS – reduce the application size in up to 70% Can be disabled using flags (No Link, Link SDK Only) or manually using attributes Mono JIT-Compiling Mono’s Simple Generational GC See tips and tricks Interaction with the OS is done using JNI (Java Native Interface) with Managed runtime wrappers
    20. 20. Xamarin Application Architecture
    21. 21. User Interface Designer Android AXml editor All standard android UI controls Built-in – both Visual Studio and Xamarin Studio iOS XCode UI designer Storyboards also supported Xamarin works directly with the XIB file Integrated designer – in Alpha
    22. 22. Code sharing ‘tactics’ File-Linking Using symbolic links to shared files from different projects Generally used with conditional compilation directives Can be used with partial classes and methods Can be hard to unit-test Requires an extra step for building the core project Portable Class Library (PCL)
    23. 23. Portable Class Library Support various deployment targets Windows 78 Desktop apps Windows 8 Store Apps Windows Phone 78 Xamarin.iOS Xamarin.Android Xbox (partial) Silverlight 45 All by using the same binary!
    24. 24. Portable Class Library – cont.
    25. 25. Portable Class Library – cont. Almost every package on NuGet comes with PCL HttpClient Immutable Collections SignalR ODataLib RESTSharp Json.Net MvvmCross TinyIoC Protobuf-net Many more..
    26. 26. MvvmCross By far the best and most robust Mvvm framework Supports: Xamarin.iOS Xamarin.Android Windows Phone Windows Store Apps WPF Mac OS X Navigation, IoC container, bindings, etc.. – One stop shop
    27. 27. Demo
    28. 28. Visual Studio Integration iOS application can be developed in Visual Studio, but you will still need a Mac For building the binaries Running the simulator Deploy to device UI using Xcode (Interface Builder) Works perfectly side-by-side – using remote build and deployment F5 on VS, the application is loaded on the iOS simulatordevice
    29. 29. Visual Studio Integration – cont. Android works within VS as any other C# project Simulator needs some tweaks for performance Intel HAXM Device deployment is the fastest
    30. 30. Xamarin Studio (monoDevelop) Fully featured, modern IDE Global type search Code Navigation Both Mac and Windows versions Much more.. NuGet support Source control SVN / GIT are supported Refactoring in Visual Studio is better Generally, great IDE (really)
    31. 31. Demo
    32. 32. Xamarin.Mobile Address book using Xamarin.Contacts; var contacts = new AddressBook (); if (await book.RequestPermission()) { contacts.OrderBy(c => c.LastName).ForEach(c => Console.WriteLine);} Geo-Location using Xamarin.Geolocation; var locator = new Geolocator { DesiredAccuracy = 50 }; Position position = await locator.GetPositionAsync (timeout: 10000); // position.Latitude, position.Longitude, etc..
    33. 33. PushSharp Server-side library for sending Push Notifications iOS (iPhone/iPad APNS) Android (C2DM and GCM - Google Cloud Message) Windows Phone Windows 8 Amazon, Blackberry too http://tinyurl.com/pushsharpsession
    34. 34. Interoperability Use native libraries as if they were written in C# You can wrap a driver for any specific platform and use it in Xamarin – specific printer, scanner, etc.. iOS Objective Sharpie – for semi-automatic wrapper generation for Objective-C drivers Android – set build action to AndroidNativeLibrary and use PInvoke
    35. 35. Make your app Xamarin-friendly Good separation between UI code and BL E.g. Do not use BitmapImage on your BL Whatever you do, do not use MEF Abstract away the IoC implementation Create abstractions for system.configuration iOS - Reflection and mtouch linker issues Android – Large object graphs on Java.Lang.Object subclasses Android – Use the x86 emulator (!) tips
    36. 36. Showcase Bastion
    37. 37. 3rd party components There is a component for almost every need Google Play Services Windows Azure Mobile Services Facebook SDK Twitter SDK PushSharp - TBD RestSharp Many more - http://components.xamarin.com/
    38. 38. Scan your code for conformance scan.xamarin.com
    39. 39. Demo
    40. 40. Licensing
    41. 41. Getting started with Xamarin Scan your code for conformance: scan.xamarin.com Download: Trial program – 30 days MSDN Subscription benefit – 90 days Tons of webinars from the last conference Great tutorials (really!)
    42. 42. Questions
    43. 43. Thank you! If you can do it in Objective-C and Java, you can do it in C# with Xamarin. Ofir Makmal - Senior Consultant Email: Ofirm@sela.co.il Blog: http://blogs.microsoft.co.il/ofirmakmal Twitter: @OfirMakmal LinkedIn: http://www.linkedin.com/in/ofirmakmal

    ×