Quick Start
Setup
The first thing is to install to your application head project (i.e. MyProject.iOS and MyProject.Android). This library contains the Shiny.Core and source generators designed to plugin all of the boilerplate code you'll need.
Add the following in some .cs file in each head project:
// NOTE THE USE OF THE FULL TYPE NAME INCLUDING NAMESPACE
[assembly: Shiny.ShinyApplication(
ShinyStartupTypeName = "MyProject.ShinyStartupClass",
XamarinFormsAppTypeName = "MyProject.XamarinFormsAppClass"
)]
where
- MyProject is your project's root namespace
- ShinyStartupClass is the name of your Shiny startup class (see next step)
- XamarinFormsAppClass is the name of your shared project App class (usually
App
)
For example, if you create a new Visual Studio project named MyApp, and in step 3 below you name your Shiny
startup class YourShinyStartup
, you would add the following to each head project:
[assembly: Shiny.ShinyApplication(
ShinyStartupTypeName = "MyApp.YourShinyStartup",
XamarinFormsAppTypeName = "MyApp.App"
)]
using Microsoft.Extensions.DependencyInjection;
using Shiny;
namespace YourNamespace
{
public class YourShinyStartup : ShinyStartup
{
public override void ConfigureServices(IServiceCollection services, IPlatform platform)
{
// this is where you'll load things like BLE, GPS, etc - those are covered in other sections
// things like the jobs, environment, power, are all installed automatically
}
}
}
For iOS AppDelegate is marked partial. If you have any methods that Shiny uses already implemented, you'll receive a build warning to manually hook the method.
For Android, Shiny will automatically create the necessary Android application class. For your main activity (or multiple activities), ensure each one is marked as partial. Shiny will again, auto hook the necessary methods.
For Android, add a reference to the
Mono.Android.Export
assembly to your Android project. Also ensure you are targeting the latest major version of Android See this StackOverflow post for the procedure.Install any of the service modules Shiny has to offer and register them with your startup. Be sure to follow any special OS setup instructions in each module.
The Shiny source generators also automatically wire the following 3rd party libraries for you:
- Xamarin Forms
- Xamarin Forms Maps
- Xamarin Essentials
- ACR User Dialogs
- AIForms Settings View
- XF Material
- RG Popups
- FFImageLoading
- Microsoft Identity Client (MSAL)
If you have a truly custom application and you have a great deal of code in your AppDelegate or Android classes, you can manually hook Shiny into these methods. Take a look at iOS Setup and Android Setup for how to do this.