If you have developed some Xamarin applications in the past, you might have stumbled on the excessive range of configuration options you can choose from. The settings you’re using in development may be very different from your Release settings. For example; you don’t want to include debug information in the app that will be published to the App Stores. It will increase the app size enormously and expose technical info about your app that might be useful to malicious people.
Besides the difference of Release and Debug configurations, you sometimes need a extra set of configurations. Visual Studio allows you to create additional build configurations:
Compiler flags / Conditional compilation symbols
Per build configuration you can also specify a set of compiler flags. Compiler flags on itself don’t have any impact on your app, but you can use these flags in your code. By default the build configuration called Debug, has a compiler flag called “Debug”. In your code you can check if this flag is set (and therefor Debug configuration is active) and execute some Debug code. A common scenario is to Log additional information when the Debug flag is set.
Using compiler flag in code:
#if Debug InitializeUiTests(); #endif
- MSDN – Build configurations: https://msdn.microsoft.com/en-us/library/kkz9kefa.aspx
- MSDN – Conditional compilation symbols: https://msdn.microsoft.com/en-us/library/aa691095(v=vs.71).aspx