cross-platform mobile development in visual studio
TRANSCRIPT
XamarinMobile Cross Platform Development in Visual Studio
bryan costanichem: [email protected]: @bryancostanichslides: slideshare.net/bryancostanich/crossplatform-mobile-development-in-visual-studio
Sample Codegithub.com/xamarin/mobile-samples/TaskyPro
Xamarin Platform
One Language + FrameworkLINQLambdasTask Parallel Library (TPL)Compile-Time ChecksGarbage Collection
C#º
Native Perf. + UXCompiles Down to Native CodeNot InterpretedAll Native UX ControlsFull Platform SDK AccessiOS: Selectors/Obj-C RuntimeAndroid: JNIFast Enough for Games
º
Reuse StoryC# LibrariesObj-C Bindings + Binding Projects.jar Bindings + Binding ProjectsC via pInvokeC++ via Cxxi
º
Other PlatformsWindows - via .NETMac - via Xamarin.MacLinux - via MonoEtc.
Community + SupportHuge C# CommunityStackOverflow.comIRC + chat.xamarin.comGreat Support
º
General XPlat Considerations
Design Platform-Specific UX
UX in iOS != Android != Windows PhoneUX Metaphors are Different: Navigation Controller vs. Back ButtonWrite-Once, Run-Anywhere is ProblematicUsers Expect Native UX
º
Choose Device TargetsiPhone != iPadBeware Android FragmentationForm Factor + Capability Differences Inform UXPro-Tip: Minimize Targets
º
Building an X-Plat Architecture
ArchitectureLayersSeparation of ResponsibilityEncapsulationCore Code Sharing
º
VS Project/Solution Setup
Code Sharing - Linking vs. PCLPortal Library Projects - Take a Lot of WorkGreat Discussion Here: http://forums.xamarin.com/discussion/28/challenges-thoughts-loves/p1Takeaway: PCL is clean, but difficult to implementLinking is less “clean” but simplerOur Recommendation Now: File Linking for Most ProjectsWalkthrough Here: Linkingº
WP7 + AndroidNew 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 2010VS MonoTouch Plugin: https://github.com/follesoe/VSMonoTouch
º
iOS - Visual Studio 2012VS MonoTouch Plugin: https://github.com/ste8/VSMonoTouchVisual Studio SDK (to build plugin): http://msdn.microsoft.com/en-us/library/bb166441(v=vs.80).aspx
iOS - Plugin ConfigCreate iOS Project (on Mac): "[AppName].iOS"Copy to Solution Directory or Synch in SourceManually Edit iOS .csproj File, add Refs ->
.csproj edit:<ItemGroup> <Reference Include="mscorlib" /> <Reference Include="monotouch" /> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> </ItemGroup>
Remove CoreLib Reference ->
Limitations: Can Build, but No Designer, or Deployment (must use Mac for now**)
º
Shared Code LinkingTwo Linking Options: Auto or ManualAuto: 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
SQLite on iOS + Android, C# SQLIte on WP7: http://code.google.com/p/csharp-sqlite/SQLite.NET ORMUse Generics for CRUD Convenience Methods: TaskDatabase.cs
º
Platform AbstractionsHandling Divergence and Taking Advantage of Platform Features
Conditional CompilationPre-Defined Symbols: #if __ANDROID__ #if WINDOWS_PHONE #if SILVERLIGHTCan Add Additional in Build Settings
Class AbstractionSometimes, You Wanna Provide Different Implementations for Different PlatformsPartial ClassesPartial MethodsInterfaces
º
Xamarin.MobileXPlat API AbstractionsXamarin.com/MobileAPI
Contacts GeolocationCompass + Accelerome
terCamera
Notifications
Other XPlat LibsMonoCross - http://code.google.com/p/monocross/MvvmCross - https://github.com/slodge/MvvmCrossVernacular - https://github.com/rdio/vernacularMonoGame - http://monogame.codeplex.com/
º
Q+A