Build multi-platform Xamarin class library – single project or multiple projects?

By | July 31, 2018
Questions:

I’m trying to build a class library that includes some platform-specific stuff, i.e. there will be multiple targets including iOS and Android in one package.

As I understand it, there are basically two ways to go:

  1. A single .csproj file with multiple TargetFrameworks. There is a Xamarin example using this approach in the article “Multi-targeting the world: a single project to rule them all”. I think it is probably out of date– when I try to build according to that example, I get errors about the various Targets files not existing at the right path. But I at least understand the basic idea.

  2. Multiple .csproj files, one for each target framework, with a .nuproj file to gather them together into a package, as described in these Microsoft docs. I’ve managed to set up a project like this and almost get it to build, although I’m still having a few problems.

I’m just wondering if one approach has clear advantages versus the other, and if there are any better examples of a solution like this that I’ve overlooked.

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *