Xamarin.Forms Projects
上QQ阅读APP看书,第一时间看更新

Setting up the project

A Xamarin app can essentially be created using one of two code-sharing strategies:

  • As a shared project 
  • As a .NET Standard library 

The first choice, a shared project, will create a project type that is essentially a linked copy of each file in it. The file exists in one common place and is linked in at build time. This means that we cannot determine the runtime when writing the code and we are only allowed to access the APIs that are available on each target platform. It does allow us to use conditional compilations, which can be useful in certain circumstances but can also be confusing for someone who reads the code later on. Going for the shared project option may also be a bad choice as it locks down our code to specific platforms.

We will use the second choice, a .NET Standard library. This is, of course, a matter of choice and both ways will still work. With a little imagination, you can still follow this chapter, even if you select a shared project.

Let's get started!