View
282
Download
2
Category
Preview:
Citation preview
Cross-Platform Mobile Development using Visual Studio and Xamarin
Shravan Kumar KasagoniSenior Developer - RealPageMicrosoft MVP – VSDTMicrosoft User Group Hyderabad @techieshravan
Agenda
Mobile development challengesNative Android, iOS and Windows applicationsCreate mobile experiencesFaster development cycles
Mobile represents the single largest technology innovation of all time
Smartphone adoption is happening
10XFaster than the PC boom of the 80s
2XFaster than the Internet boom of the 90s
3XFaster than the recent social networking explosion
Extend to any device
Take advantage of cloud scale and economics
Business agility
Core-businessApplications
Mobile apps are part of a broader modernization
Mobile
Cloud
Agile
Approaches for device development
Native Hybrid
Tool maturity
Device optimized experience
Updatability
Portability across devices
Write-once-run-anywhere approachHybrid apps. Presentation written in HTML/CSS and behavior written in JavaScript/TypeScriptHighest code reuse ratio at UI expensePerformance depends on the containerApache Cordova/Ionic
Write-once-run-anywhere
box
CSS • HTML • TypeScript • JavaScript • Ionic • …
Hybrid app build-in support with Cordova.Full developer workflow for coding, debugging, and instrumenting device hybrid apps.Visual Studio productivity for Android, iOS, and Windows devices.
Web and hybrid apps
+ Integrated hybrid app support
Black Box
CSS | HTMLJavaScript | TypeScript
Powerful IDE for HTML5 / CSS3.Highly interactive JavaScript-based apps.Suited for LOB browser-based apps.
Web development with Visual Studio
Native mobile apps are better…
- Performance - Richness of UI
Silo’ed approach
Building native apps multiple times meansClient development is completely different for each device typeOnly the Services (server-side) can be reused, with certain differences when consuming themTCO grows exponentially
Objective-C, SwiftXCode
JavaEclipse
C#, JS, C++Visual Studio
Using the platform’s native tools (Siloed approaches are long term problems)
Xcode ADT Visual Studio
…Multiple code bases and skills, fragmented tools, different teams
End user experienc
e
Better productivity andglobal developer
experience
✗ Great apps, but…
Building native apps multiple times when targeting multiple
platforms!
…very expensive,not sustainable…
+
+
-
C# and Xamarin to the rescue!
How?
Mono Framework
What is Mono?• Open source implementation of the .NET platform created
by Ximian (ECMA 334/335)
• 2001: Created to bring Windows applications to Linux
• 2003: Acquired by Novell with Ximian
• Matured at Novell in research mode; now a world-class runtime.
Bringing .NET to Linux
Windows Linux
Microsoft .NET
.NET Apps
Mono/.NET Core
.NET Apps
.NET on Android, iOS
Linux
Mono
iOS
Mono Touch
Android
Mono for Android
iOS
Xamarin.iOS
Android
Xamarin.Andriod
Xamarin• Founded in May 2011
• Xamarin has a perpetual license to all Mono IP: Copyrights, patents and trademarks
• Focused on mobile app development
Bringing .NET to Android
Android Kernel
Mono Runtime
.NET APIs
Apps
Android Bindings
Dalvik Runtime/ART
android.* java.*MCW
ACW
Bringing .NET to iOS
iOS
Mono Runtime
NO RUNTIMES ALLOWED
Bringing .NET to iOS
iOS
App
.NET APIS iOS Bindings
Application Code
Anything you can do in Objective-C, Swift, or Java; can be done in C#
Microsoft supports your choice
.NET Desktop apps Universal Windows apps
HTMLBrowser-based applications
Rich experiences Breadth of devices
Xamarin and Visual Studio
Black Box
Shared code across platforms
with C# and Portable Libraries
Native UI or shared user experiences
with Xamarin.Forms
C# in Xamarin+ Visual Studio 1iPhone native (C# and XIB)
2Android native (C# and AXML)
3Windows Store (C# and XAML)
4 Native apps and cross-platform UI (C# and Xamarin.Forms)
Cross-platform with C#
C# + XIB C# + AXML C# + XAMLiPhone Android Windows
Shared client app C# code
Xamarin provides native cross-platform for iOS and Android.Share app logic code across device platforms.Common cross-platforms UX with Xamarin.Forms.
Cross-platform mobile native apps for iOS, Android, and Windows devices with C#Cross-platform with
Xamarin
Full access to device features with 100% APIs exposed, everything you can do in xCode or ADT (Android Development Tools) you can do with C# and Xamarin.Highly flexibility and customization apps for each target device.Best UX and performance in devices.
Native apps in C#
Xamarin.iOS does 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 (JIT) compilation on the Android device
Native cross-platform apps with Xamarin
Native compilation, native performance
C# unique approach powered by .NET and XamarinThe best of both worlds (UX & TCO)
Great native apps delivered to the user’s choice of device
Development agility, with Visual Studio to move at mobile speed
End user experienc
e
Developer experienceBetter TCO and productivity
Create UI with drag and drop simplicity.Target multiple screen sizes, resolutions, and OS versions.Layouts saved in native resource formats.World’s best Android designer available in Visual Studio.Xamarin 3 designer in Visual Studio, for iOS.
UI design in Visual Studio
Xamarin designer for Android apps
Xamarin designer for iOS apps
WindowsAPIs
100%coveragewith .NET
iOSAPIs
100%coveragewith Xamarin
AndroidAPIs
100%coveragewith Xamarin
Maximizing code reuse across platforms
ViewsHow to display information
View modelsWhat information to displayFlow of interaction
ModelsData objectsBusiness logicEtc.
Model
View Model
View Device-specific
Portable codeReferences
Databinds
Implemented in PCL or shared project
Demo
Xamarin + C# + Visual Studio
Sharing code
Sharing codeOne of the main reasons to use Xamarin is the possibility of sharing a significant portion of your code across all your supported platforms
Sharable CodeXamarin applications arenative and therefore willalways include someplatform-specific code
30%
70%
iOS14%
86%
Android
15%
86%
Windows Phone
Platform Specific
Cross Platform
Where can I use shared code?Anytime you are writing code which does not depend on a specific platform feature, it is potentially sharable, particularly if it:
• Talks to a web service• Parses a data format• Uses a database• Performs processing or logic
Create shared classes + methods and then use them from your platform-specific code to maximize the shareable surface area
Where can I use shared code?Data Access (Database)• SQLite support available for iOS, Android and Windows• Can also store in the cloud – Azure Mobile Services, Amazon,
Dropbox, etc.
Web Services• Use HttpClient for REST services
Xamarin.* Libraries• Xamarin.Social• Xamarin.Auth• Xamarin.MobileOpen-Source, Cross-Platform APIs available from Github.com/Xamarin
When is code not sharable?If the code you are writing depends on device or platform-specific APIs, or APIs not available in your project, then you will need to isolate it's use or provide some kind of abstraction to use it from your shared code
• Access system information• Use files and folders on the device• Access personal information• Use external devices
Xamarin Component StoreCan also get reusable components from the Xamarin Component Store which is accessible through the Components folder in each project
Available project typesThere are two project styles available for sharing code – which one youselect has an impact on how and what kind of code is shared
Shared Project Portable Class Library
Demo
Shared Projects
Demo
Portable Class Library
Thank You
Recommended