I am currently building an iOS application using Xamarin and was looking to implement a settings bundle so that our QA department can point the app to the appropriate API environment.
What I am looking at doing is including or excluding the Settings bundle in the Xamarin iOS app based on the build configuration as I may not want to expose this data to the user in Release mode.
Can you include or exclude the Settings bundle or even change the bundle that is compiled into the app based on the build configuration?
(I gotten asked this so many times :-) , I figured I would expand my original answer.)
So as an example, in Debug
mode, I want to include a Setting.bundle
that consists of Root.plist
and a submenu Extra.plist
.
In Release
mode, I want to include a totally different Root.plist
and no Extra.plist
in the app's Setting.bundle
My .csproj
file is going to look like this:
<ItemGroup Condition="'$(Configuration)'!='Debug'">
<BundleResource Include="Settings.bundle\Root.plist" >
</BundleResource>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Debug'">
<BundleResource Include="Settings.debug\Extra.plist" >
<Link>Settings.bundle\Extra.plist</Link>
</BundleResource>
<BundleResource Include="Settings.debug\Root.plist" >
<Link>Settings.bundle\Root.plist</Link>
</BundleResource>
</ItemGroup>
Note:
As shown below, in Debug
Xamarin is including additional menu items into my Root.plist and in Release
they are not. Also my Additional Settings
submenu is no longer available and now are labeled with XXXX Release
Debug mode result:
Release mode result:
Apart from conditional including of different settings bundle you will probably also need to conditionally read the settings in your app. You can use conditional compilation to either read from settings or use hard coded values:
#if DEBUG
//Read from settings
#else
//Use other values.
#endif