SlideShare a Scribd company logo
Xamarin
Mobile Cross Platform Development in Visual Studio
bryan costanich
em: bryanc@xamarin.com
tw: @bryancostanich
slides:
slideshare.net/bryancostanich/crossplatform-
mobile-development-in-visual-studio
Sample Code
github.com/xamarin/mobile-samples/TaskyPro
Xamarin Platform
One Language +

                                  C#
    Framework
    LINQ
    Lambdas
    Task Parallel Library (TPL)
    Compile-Time Checks
    Garbage Collection



º
Native Perf. + UX
    Compiles Down to Native Code
    Not Interpreted
    All Native UX Controls
    Full Platform SDK Access
    iOS: Selectors/Obj-C Runtime
    Android: JNI
    Fast Enough for Games

º
Reuse Story
    C# Libraries
    Obj-C Bindings + Binding Projects
    .jar Bindings + Binding Projects
    C via pInvoke
    C++ via Cxxi




º
Other Platforms
Windows - via .NET
Mac - via Xamarin.Mac
Linux - via Mono
Etc.
Community +
    Support
    Huge C# Community
    StackOverflow.com
    IRC + chat.xamarin.com
    Great Support




º
General XPlat Considerations
Design Platform-Specific UX
    UX in iOS != Android != Windows
    Phone
    UX Metaphors are Different:
    Navigation Controller vs. Back
    Button
    Write-Once, Run-Anywhere is
    Problematic
    Users Expect Native UX
º
Choose Device
    Targets
    iPhone != iPad
    Beware Android Fragmentation
    Form Factor + Capability Differences
    Inform UX
    Pro-Tip: Minimize Targets


º
Building an X-Plat Architecture
Architecture
    Layers
    Separation of Responsibility
    Encapsulation
    Core Code Sharing




º
VS Project/Solution Setup
Code Sharing - Linking vs. PCL
    Portal Library Projects - Take a Lot of Work
    Great Discussion Here:
    http://forums.xamarin.com/discussion/28/challenges-thoughts-loves/p1
    Takeaway:
    PCL is clean, but difficult to implement
    Linking is less “clean” but simpler
    Our Recommendation Now: File Linking for Most Projects
    Walkthrough Here: Linking

º
WP7 + Android
    New Blank Solution: "[AppName]"
    New C# Lib Project: "[AppName].Core"
    Test Project: “[AppName].Core.Tests”
    New Mono for Android Project: “[AppName].Droid”
    New WP7 Project "[AppName].WP7"




º
iOS - Visual Studio 2012
    VS MonoTouch Plugin:
      https://github.com/ste8/VSMonoTouch
    Visual Studio SDK (to build plugin):
      http://msdn.microsoft.com/en-us/library/bb166441(v=vs.80).aspx


    iOS - Visual Studio 2010
    VS MonoTouch Plugin:
     https://github.com/follesoe/VSMonoTouch


º
.csproj edit:
    iOS - Plugin Config                           <ItemGroup> <Reference
                                                  Include="mscorlib" />
    Create iOS Project (on Mac): "[AppName].iOS"<Reference
    Copy to Solution Directory or Synch in Source Include="monotouch" />
    Manually Edit iOS .csproj File, add Refs ->   <Reference
                                                  Include="System" />
    Remove CoreLib Reference ->                   <Reference
                                                  Include="System.Xml" />
    Limitations: Can Build, but No Designer, or   <Reference
    Deployment                                    Include="System.Core" />
     (must use Mac for now**)                         </ItemGroup>

º
Shared Code Linking
    Two Linking Options: Auto or Manual
    Auto: Use Project Linker VS Add-In
     Add a project link, voila. (2010 + 2012)
    Manual: Link Files
     Add Files as Links




º
Shared Data +
    Data Access
    Layer
    Data Access
    Layer
    SQLite on iOS + Android, C# SQLIte on WP7:
     http://code.google.com/p/csharp-sqlite/
    SQLite.NET ORM
    Use Generics for CRUD Convenience Methods:
     TaskDatabase.cs



º
Platform Abstractions
Handling Divergence and Taking Advantage of Platform
Features
Conditional
Compilation
Pre-Defined Symbols:
 #if __ANDROID__
 #if WINDOWS_PHONE
 #if SILVERLIGHT
Can Add Additional in Build Settings
Class Abstraction
    Sometimes, You Wanna Provide
    Different Implementations for Different
    Platforms
    Partial Classes
    Partial Methods
    Interfaces




º
Xamarin.Mobile
XPlat API Abstractions
Xamarin.com/MobileAPI


                              Compass +
  Contacts     Geolocation   Acceleromete   Camera   Notifications
                                   r
Other XPlat Libs
    MonoCross - http://code.google.com/p/monocross/
    MvvmCross - https://github.com/slodge/MvvmCross
    Vernacular - https://github.com/rdio/vernacular
    MonoGame - http://monogame.codeplex.com/




º
Q+A

More Related Content

What's hot (20)

PDF
Modern JavaScript Frameworks: Angular, React & Vue.js
Jonas Bandi
 
PDF
30 Tools for Modern .NET Web Development in 60 Minutes (Jonathan Tower)
ITCamp
 
PDF
Parse par Nicolas Lauquin
CocoaHeads France
 
PDF
Lezione 02 React and React Native installation and Configuration
University of Catania
 
PDF
Frontend Monoliths: Run if you can!
Jonas Bandi
 
PDF
Electron JS | Build cross-platform desktop applications with web technologies
Bethmi Gunasekara
 
PPTX
BlackBerry WebWorks
Bhasker Thapan
 
PDF
20150728 100분만에 배우는 windows 10 앱 개발
영욱 김
 
PPTX
JavaScript on HP webOS: Enyo and Node.js
Ben Combee
 
PDF
CapitolJS: Enyo, Node.js, & the State of webOS
Ben Combee
 
PPT
An Introduction to Google Chrome OS..........
VAST TRICHUR
 
PDF
Building a Next Generation Mobile Browser using Web technologies
n_adam_stanley
 
PDF
Ionic adventures - Hybrid Mobile App Development rocks
Juarez Filho
 
PPTX
Google chrome
Nayana_Bingi
 
PPTX
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Nicholas Jansma
 
PDF
Ionic framework one day training
Troy Miles
 
PDF
Sencha touchonbb10 bootcamp
n_adam_stanley
 
PDF
Sg conference multiplatform_apps_adam_stanley
n_adam_stanley
 
PDF
What's new in ios 7.0
CocoaHeads France
 
Modern JavaScript Frameworks: Angular, React & Vue.js
Jonas Bandi
 
30 Tools for Modern .NET Web Development in 60 Minutes (Jonathan Tower)
ITCamp
 
Parse par Nicolas Lauquin
CocoaHeads France
 
Lezione 02 React and React Native installation and Configuration
University of Catania
 
Frontend Monoliths: Run if you can!
Jonas Bandi
 
Electron JS | Build cross-platform desktop applications with web technologies
Bethmi Gunasekara
 
BlackBerry WebWorks
Bhasker Thapan
 
20150728 100분만에 배우는 windows 10 앱 개발
영욱 김
 
JavaScript on HP webOS: Enyo and Node.js
Ben Combee
 
CapitolJS: Enyo, Node.js, & the State of webOS
Ben Combee
 
An Introduction to Google Chrome OS..........
VAST TRICHUR
 
Building a Next Generation Mobile Browser using Web technologies
n_adam_stanley
 
Ionic adventures - Hybrid Mobile App Development rocks
Juarez Filho
 
Google chrome
Nayana_Bingi
 
Debugging IE Performance Issues with xperf, ETW and NavigationTiming
Nicholas Jansma
 
Ionic framework one day training
Troy Miles
 
Sencha touchonbb10 bootcamp
n_adam_stanley
 
Sg conference multiplatform_apps_adam_stanley
n_adam_stanley
 
What's new in ios 7.0
CocoaHeads France
 

Similar to Cross-Platform Mobile Development in Visual Studio (20)

PDF
Building Cross-Platform Mobile Apps
Troy Miles
 
PPT
State ofappdevelopment
gillygize
 
PPT
C# rocks
bryan costanich
 
PDF
Bienvenido .Net MAUI - la evolución de Xamarin.Forms
Vicente Gerardo Guzman Lucio
 
PPT
Synapseindia android apps intro to android development
Synapseindiappsdevelopment
 
PDF
Visual Studio 2017 Launch Event
James Montemagno
 
PPTX
Android crash course
Showmax Engineering
 
PDF
Flutter vs Java Graphical User Interface Frameworks - text
Toma Velev
 
PDF
Visual Studio for Mac (AltConf 2017)
Craig Dunn
 
PPT
Cross-platform mobile dev with Mono
Craig Dunn
 
PDF
Electron
Mark Lechtermann
 
PDF
4. RTFM, 나는프로그래머다 Meetup 2016 / 한국마이크로소프트 김명신 기술 에반젤리스트
양 한빛
 
PPTX
Welcome to the microsoft madness
명신 김
 
PPTX
Cross platform mobile app development tools review
Uday Kothari
 
PDF
Firefox OS - Hive Pilani 2015
Nilay Binjola
 
PPTX
Angularjs Tutorial for Beginners
rajkamaltibacademy
 
PDF
Tutorial: Develop Mobile Applications with AngularJS
Philipp Burgmer
 
PPTX
Mobile Application and Developments.pptx
GevitaChinnaiah
 
PPTX
Cloud development technology sharing (BlueMix premier)
湯米吳 Tommy Wu
 
PDF
Droidcon uk2012 androvm
dfages
 
Building Cross-Platform Mobile Apps
Troy Miles
 
State ofappdevelopment
gillygize
 
C# rocks
bryan costanich
 
Bienvenido .Net MAUI - la evolución de Xamarin.Forms
Vicente Gerardo Guzman Lucio
 
Synapseindia android apps intro to android development
Synapseindiappsdevelopment
 
Visual Studio 2017 Launch Event
James Montemagno
 
Android crash course
Showmax Engineering
 
Flutter vs Java Graphical User Interface Frameworks - text
Toma Velev
 
Visual Studio for Mac (AltConf 2017)
Craig Dunn
 
Cross-platform mobile dev with Mono
Craig Dunn
 
4. RTFM, 나는프로그래머다 Meetup 2016 / 한국마이크로소프트 김명신 기술 에반젤리스트
양 한빛
 
Welcome to the microsoft madness
명신 김
 
Cross platform mobile app development tools review
Uday Kothari
 
Firefox OS - Hive Pilani 2015
Nilay Binjola
 
Angularjs Tutorial for Beginners
rajkamaltibacademy
 
Tutorial: Develop Mobile Applications with AngularJS
Philipp Burgmer
 
Mobile Application and Developments.pptx
GevitaChinnaiah
 
Cloud development technology sharing (BlueMix premier)
湯米吳 Tommy Wu
 
Droidcon uk2012 androvm
dfages
 
Ad

More from bryan costanich (8)

PDF
Hardware hackers - hacking appliances with netduino + xamarin
bryan costanich
 
PDF
Teardown Conference: hacking appliances with netduino + xamarin
bryan costanich
 
PPTX
Hacking your coffee maker; building a connected appliance with Netduino and X...
bryan costanich
 
PPTX
Futures in Computing
bryan costanich
 
PPT
Advanced android app lifecycle + Patterns
bryan costanich
 
PPT
Cross Platform Mobile Development with Xamarin
bryan costanich
 
KEY
Going mobile - A Technical Job Prep for Vassar Students
bryan costanich
 
KEY
Cross Platform Development with Xamarin
bryan costanich
 
Hardware hackers - hacking appliances with netduino + xamarin
bryan costanich
 
Teardown Conference: hacking appliances with netduino + xamarin
bryan costanich
 
Hacking your coffee maker; building a connected appliance with Netduino and X...
bryan costanich
 
Futures in Computing
bryan costanich
 
Advanced android app lifecycle + Patterns
bryan costanich
 
Cross Platform Mobile Development with Xamarin
bryan costanich
 
Going mobile - A Technical Job Prep for Vassar Students
bryan costanich
 
Cross Platform Development with Xamarin
bryan costanich
 
Ad

Recently uploaded (20)

PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
July Patch Tuesday
Ivanti
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
July Patch Tuesday
Ivanti
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 

Cross-Platform Mobile Development in Visual Studio

  • 1. Xamarin Mobile Cross Platform Development in Visual Studio
  • 2. bryan costanich em: [email protected] tw: @bryancostanich slides: slideshare.net/bryancostanich/crossplatform- mobile-development-in-visual-studio
  • 5. One Language + C# Framework LINQ Lambdas Task Parallel Library (TPL) Compile-Time Checks Garbage Collection º
  • 6. Native Perf. + UX Compiles Down to Native Code Not Interpreted All Native UX Controls Full Platform SDK Access iOS: Selectors/Obj-C Runtime Android: JNI Fast Enough for Games º
  • 7. Reuse Story C# Libraries Obj-C Bindings + Binding Projects .jar Bindings + Binding Projects C via pInvoke C++ via Cxxi º
  • 8. Other Platforms Windows - via .NET Mac - via Xamarin.Mac Linux - via Mono Etc.
  • 9. Community + Support Huge C# Community StackOverflow.com IRC + chat.xamarin.com Great Support º
  • 11. Design Platform-Specific UX UX in iOS != Android != Windows Phone UX Metaphors are Different: Navigation Controller vs. Back Button Write-Once, Run-Anywhere is Problematic Users Expect Native UX º
  • 12. Choose Device Targets iPhone != iPad Beware Android Fragmentation Form Factor + Capability Differences Inform UX Pro-Tip: Minimize Targets º
  • 13. Building an X-Plat Architecture
  • 14. Architecture Layers Separation of Responsibility Encapsulation Core Code Sharing º
  • 16. Code Sharing - Linking vs. PCL Portal Library Projects - Take a Lot of Work Great Discussion Here: http://forums.xamarin.com/discussion/28/challenges-thoughts-loves/p1 Takeaway: PCL is clean, but difficult to implement Linking is less “clean” but simpler Our Recommendation Now: File Linking for Most Projects Walkthrough Here: Linking º
  • 17. WP7 + Android New Blank Solution: "[AppName]" New C# Lib Project: "[AppName].Core" Test Project: “[AppName].Core.Tests” New Mono for Android Project: “[AppName].Droid” New WP7 Project "[AppName].WP7" º
  • 18. iOS - Visual Studio 2012 VS MonoTouch Plugin: https://github.com/ste8/VSMonoTouch Visual Studio SDK (to build plugin): http://msdn.microsoft.com/en-us/library/bb166441(v=vs.80).aspx iOS - Visual Studio 2010 VS MonoTouch Plugin: https://github.com/follesoe/VSMonoTouch º
  • 19. .csproj edit: iOS - Plugin Config <ItemGroup> <Reference Include="mscorlib" /> Create iOS Project (on Mac): "[AppName].iOS"<Reference Copy to Solution Directory or Synch in Source Include="monotouch" /> Manually Edit iOS .csproj File, add Refs -> <Reference Include="System" /> Remove CoreLib Reference -> <Reference Include="System.Xml" /> Limitations: Can Build, but No Designer, or <Reference Deployment Include="System.Core" /> (must use Mac for now**) </ItemGroup> º
  • 20. Shared Code Linking Two Linking Options: Auto or Manual Auto: Use Project Linker VS Add-In Add a project link, voila. (2010 + 2012) Manual: Link Files Add Files as Links º
  • 21. Shared Data + Data Access Layer Data Access Layer SQLite on iOS + Android, C# SQLIte on WP7: http://code.google.com/p/csharp-sqlite/ SQLite.NET ORM Use Generics for CRUD Convenience Methods: TaskDatabase.cs º
  • 22. Platform Abstractions Handling Divergence and Taking Advantage of Platform Features
  • 23. Conditional Compilation Pre-Defined Symbols: #if __ANDROID__ #if WINDOWS_PHONE #if SILVERLIGHT Can Add Additional in Build Settings
  • 24. Class Abstraction Sometimes, You Wanna Provide Different Implementations for Different Platforms Partial Classes Partial Methods Interfaces º
  • 25. Xamarin.Mobile XPlat API Abstractions Xamarin.com/MobileAPI Compass + Contacts Geolocation Acceleromete Camera Notifications r
  • 26. Other XPlat Libs MonoCross - http://code.google.com/p/monocross/ MvvmCross - https://github.com/slodge/MvvmCross Vernacular - https://github.com/rdio/vernacular MonoGame - http://monogame.codeplex.com/ º
  • 27. Q+A

Editor's Notes

  • #7: Fast Enough for Games Native UX means that apps look like they belong Full platform SDK Access means that anything you can do in Obj-C on iOS or Java in Android, you can do here. Animation libraries, Media libraries, etc.
  • #8: Need better graphic for this.
  • #11: Need Visual Studio Screenshot
  • #16: A good layered architecture allows for proper separation of responsibility and encapsulation, providing isolation to allow for code changes and maximizing code sharing between platforms. It also provides a pattern-agnostic framework so you can pick and choose which patterns you want to use, and then be flexible to changing them later on. And this is very simple to do. We’ll see later on how to accomplish this with proper namespacing and project setup.
  • #18: Xamarin supports portable library projects, but they pose practical problems in real-world scenarios because of dependencies. it eliminates the ability to use ifDefs, so you have to do massive architectural refactoring, use the provider/simple dependency pattern, etc. to solve even minor things. Best way, instead is to link your code.
  • #20: Don’t use .Android - the namespace will cause you hell
  • #21: Download install, and configure the plugin as state on the git page. Must create the initial MonoTouch application on a mac. Copy it over to your VS machine, into your project. or just synchronize in your source control. Edit the &lt;ItemGroup&gt; that has the “System” entry to include the mscorlib and monotouch items Finally, remove the mscorlib.dll reference in project settings : build : advanced.
  • #22: Download install, and configure the plugin as state on the git page. Must create the initial MonoTouch application on a mac. Copy it over to your VS machine, into your project. or just synchronize in your source control. Edit the &lt;ItemGroup&gt; that has the “System” entry to include the mscorlib and monotouch items Finally, remove the mscorlib.dll reference in project settings : build : advanced.
  • #23: Xamarin supports portable library projects, but they pose practical problems in real-world scenarios because of dependencies. it eliminates the ability to use ifDefs, so you have to do massive architectural refactoring, use the provider/simple dependency pattern, etc. to solve even minor things. Best way, instead is to link your code. There are two ways to do this. The magical way, or the manual way. Automatic linking is done fia the Project Linker VS Add-in. Manual is just plain old file links - your only option in MD. Simply add a project link to the corelib, and when you add/remove classes there, they’ll show up in your app projects. if you put your classes in folders, they’ll link nicely into your apps. The manual way is to simply add existing files and make sure they’re added as links.
  • #24: You can use SQLite on all three mobile platforms, iOS, Android, and WP7. on iOS and Android, SQLite is bundled with it, and on Windows Phone, you can use the open source C# port. We’ll show later how to easily support this cross platform with the same exact API. Additionally, we recommend SQLite.NET ORM for easy data access. For Data Access, we’ve added some nice convenience methods in TaskDatabase.cs that make the basic CRUD operations a snap with zero code.
  • #25: Platforms are different. pInvoke is available on iOS and Android, not on WP. SQLite is native on Android and iOS, on WP you have to use the C# lib. Devices also have different features. Cameras are different on nearly every single android device out there. Some devices have location features, some don’t. Some vary, etc.
  • #26: There are predefined symbols that allow you to use different code, depending on the platform you’re building for. Additionally, you can define your own symbols in Build Settings. Demo of this in use can be found here: TaskyPro :: CoreLib.DataLayer/SQLite.cs
  • #27: ITask - Interface TaskBase - Task class DialogTask - with MT.D annotations