Lessons from Xamarin
Development
Mark Gibaud - Developer @ JustGiving
What is Xamarin?
In the beginning
Hybrid vs Native
Initial Findings
Goodbye Resharper :-/
VS Integration Flaky
• Started talking about product features
• ..while building out technical capabilities
• Team = Team++;
• XS more stable, updates more stable
Things settled
Some utilities
• MvvmCross
• RestSharp -> ModernHttpClient + Json.NET
• SQLite.NET + Async
• Azure Mobile Services
Xamarin Bindings
• Repo of monotouch/xamarin bindings:
• https://github.com/mono/monotouch-bindings
• Make your own with ObjectiveSharpie
• We made a KissMetrics binding
• Official Xamarin Bindings not around yet, merchants
tardy
Architecture
Example: SQLite
public class Repository : IRepository
{
private readonly IPlatform _platform;
private SqliteDB _db;
public Repository(IPlatform platform)
{
_platform = platform;
_db = new SqliteDB(_platform.Path);
}
}
JG.Mobile.Core
JG.Mobile.iOS
public void Setup()
{
IoC.Bind<IPlatform,JG.Mobile.iOS.Platform>()
}
Our Architecture
Testing
• Unit Testing lite
• Automated UI Testing:
• Spiked Calabash
• Looking at TestCloud
• Xamarin.UITest
Continuous Integration
• Jenkins +
• Signing key
• Github integration
• Hipchat integration
• TestFlight integration
IB vs UI-in-code
Conclusions
• Potentially a lot to learn
• An investment
• Finding devs is harder
• Cheapest/best way to get to both platforms with
delightful user experience?
Questions?
mark.gibaud@justgiving.com
@markgibaud

JustSharing: Lessons in Xamarin development

Editor's Notes

  • #2 Quick show of hands: Who’s heard of Xamarin? Who played around with it at home? Who’s developing in professional capacity in Xamarin?
  • #3 Who are JustGiving? We have charities, we have people wanting to raise money for them by doing events We connect people with the causes that they care about Charities are a more managed relationship Naturally we have a heavy focus on the consumer side of things (our fundraisers), and this extends to mobile platforms So far used AGENCIES for app dev with mixed results Mature Public API to leverage
  • #4 About 3 1/2 years old now, still feels new though Based on Mono (open source implementation of C#, over a decade old) Surfaces all the native APIs, and actually adds a little bit here and there to improved things, eg. strongly-typed collections, combines two delegates into one. Google Glass development kit!
  • #5 Hybrid vs Native: JS Slow / Native more responsive ‘LCD’ presentation/views Native quicker to keep up with new device capabilities Solution to a problem that not everyone has (limited budget to get onto both platforms) Late last year we started the conversation Up till then only agency apps - may be kind to say “mixed results” Xamarin looked like a good bet, so we spiked something in a couple of weeks, then when my project ended I moved onto laying more foundations, get up and running with the toolset etc.
  • #6 Got up and running Jan/Feb this year Starting out wasn’t that easy Coming from mature web app codebase where everything worked including mature toolset etc Working with two laptops over network feedback loop too slow VS would drop the connection to the Mac build Xamarin.iOS Build Host improved things VS had some quirks that you could only figure out from the forums XS would handle resource files properly XS no nuget support Xamarin upgrades would also break things in interesting ways Eventually moved over to mac entirely, using Xamarin Studio XS was a learning curve SUSPECT still the least friction way to build on iOS if you have the time and patience to adapt to a new IDE? Key observation here: not much code being banged out (with the right tools)! PLUS I think Mac’s are better machines than windows laptops.
  • #7 Let fundraisers manage their own fundraising pages Get notifications of donations Get Design and UX involved at that point for prototyping Spikes: Database Storage, Notifications backend infrastructure, getting some 3rd party stuff integrated like New Relic (APM) and KissMetrics (Analytics) Also include: X-Plat from start (Android); async/await for responsive UI From dev perspective, it was good to have a bit of time to lay the foundations properly without having to deliver finished features Team ++; (Contractor) Had to build everything from scratch, spike out some things, figure out an architecture that worked, swap out some tools when we figured they weren’t quite right, etc. - all this free from having to deliver finished features. XS fewer crashes, nuget support, PCL situation ironed out
  • #8 MvvmCross: No doubt helpful, thoughts are evolving. Definitely recommended for your first app. RestSharp (non PCL) -> ModernHttpClient ModernHttpClient uses native implementations for Http (NSUrl*, OkHttp) Important for APM stuff as well Looked at CouchBaseLite (I secretly hope for MongoDB) SQLite no FK support etc. & I hate relational DBs, so for now end we’ve gone for a one-table two-column solution; No alter scripts; Simpler with the right serialisation Azure Mobile Services (Notifications): Was a cinch. Big fan of Azure. NodeJS -> C# (Notification Hubs) etc
  • #9 - Another benefit of Xamarin just being C# wrapper over ObjC is Xamarin Bindings Repo includes Analytics, App Deployment libraries like TestFlight, HockeyApp, etc. Obviously prefer native .NET wrappers when you can find them, eg. Facebook
  • #10 Some 3rd parties libraries can go straight into PCL, eg. Facebook (just an OAuth wrapper) - Miguel de Icaza calls this “Pure PCL” “Advanced PCL” - Best use of IoC since testability
  • #11 - Popular way to supply your packages on mobile now - Azure Mobile Services also uses this - ModernHttpClient (NSUrl* stuff gets injected etc) - all packaged up in one assembly
  • #12 Platform services - include things like Backgrounding / iBeacon - not view related but platform specific
  • #13 Not too bothered with Unit Testing some isolated bits where it makes sense Automated UI Testing Spike code that has been rewriting Automated UI testing with Calabash: Ruby heterogenic? TestCloud: What it says on the tin Looks compelling Xamarin.UITest wrapper around the same HTTPServer that Calabash uses only available with TestCloud atm Not cheap!
  • #14 Happy story: A situation where you can bring the maturity of other tools to the mobile space Command line tools work pretty well mdtool does the hard work (runs several more command line tools) Some potential gotchas: Export signing key from a devs machine, uses a license seat (get 4), Xamarin build license.
  • #15 - Not very mature yet; Introductory /intermediate stuff They are promising some good stuff coming soon; That said - pick up a lot of little tips between the cracks, “oh btw use this tool to do” Office hours (30 min code reviews?)
  • #16 - Never been a fan of WSYWIG editors Ultimately, we’ve used it sparingly UI-in-code (some table cells in IB) Autolayouts - rubbish in Xcode 4.0 apparently Just learn the code Like GUI vs CommandLine debate
  • #17 Xamarin is potentially a lot to learn (Macs, xamarin.NET/PCLs, XS, CocoaTouch, ObjC) Buying: Macbooks/iMacs, Apple Developer Licenses, Xamarin per platform per developer per year licenses, Xamarin University subscriptions, TestCloud subscriptions, etc Finding devs proving to be harder Traditional Mobile devs won’t come to the .Net platform just to get 2 platforms Traditional .NET devs for whatever reason not interested in Mobile dev (lots of exciting things happening in web world)
  • #18 Xamarin is potentially a lot to learn (Macs, xamarin.NET/PCLs, XS, CocoaTouch, ObjC) Buying: Macbooks/iMacs, Apple Developer Licenses, Xamarin per platform per developer per year licenses, Xamarin University subscriptions, TestCloud subscriptions, etc Finding devs proving to be harder Traditional Mobile devs won’t come to the .Net platform just to get 2 platforms Traditional .NET devs for whatever reason not interested in Mobile dev (lots of exciting things happening in web world)