This document summarizes cross-platform mobile development using Visual Studio and Xamarin. It discusses using Xamarin to build and debug iOS applications on Windows. It introduces portable class libraries (PCLs) to reuse code across platforms. It recommends using MVVM pattern with view models, models, and views to maximize code reuse. It describes the MvvmCross framework to create cross-platform MVVM apps for Windows Phone, Android, iOS and more. It also discusses using plugins and dependency injection to access platform-specific functionality in a reusable way.
9. Build and debug iOS applications on a Windows computer using the Visual Studio
IDE
Windows
Windows 7 or higher.
Visual Studio 2010 Professional or higher.
Xamarin’s plug-in for Visual Studio.
MAC
A Macintosh running OS X Lion or higher (although we recommend the latest
version).
Xamarin iOS SDK.
Apple’s Xcode IDE and iOS SDK (we recommend the latest version from the
App Store).
Xamarin.iOS on Windows
13. Use PCLs
Use View Models to reuse presentation code
Heavy use of dependency injection
Allows different implementations for different platforms
Improving Code Reuse in 3 easy ways
14.
15. Create a single library that can be
used by multiple .net frameworks
Allows access only to functionality
shared by all selected frameworks
Does some nifty namespace
mapping
Makes cross platform development
much easier
Microsoft and 3rd party PCLs
available (HttpClient, Imaging,
JSON…)
Portable Class Libraries
19. Maximizing code reuse
How to display information
What information to display
Flow of interaction
Data objects
Business logic
Etc.
Model
View Model
View Device-specific
Portable codeReferences
Databinds
24. Convenient way to access platform functionality
Use NinjaCoder or Nuget to add plugins
Includes Accelerometer, Email, Files, Location, Messaging, Sqlite
3rd party plugins available as well.
Consume plugins using Dependency Injection or Service locator
MvvmCross Plugins
25.
26.
27. Describe functionality using an interface in .Core
Create platform specific implementation in .xxxx
Register implementation on app startup
Mvx.RegisterSingleton<ISettingsPersistance>(new SettingsPersistanceWPF());
Mvx.RegisterType<IGetRemoteData, RemoteDataWpf>();
Consume plugins using Dependancy Injection or Service locator
persistance = Mvx.Resolve<ISettingsPersistance>();
Platform specific code
30. PCLs let you use easily share code across multiple platforms
Xamarin lets you use C# on Android, iOS and Mac
MvvmCross wraps it all up to make it easy
Shared PCL that holds most functionality
Platform specific apps for views and dependant code
Plugins let you easily add functionality in a cross platform friendly way
Do your own platform dependant stuff using interfaces and
IoC/Dependancy Injection
Summary