Skip to content

Tokenized Android & iOS Configurations

Dan Siegel edited this page Mar 14, 2018 · 1 revision

The build tools allow you to exclude app manifests from Source Control. To do this of course you will need to add the file(s) you wish to exclude in your .gitignore, then you will need to add a Tokenized Template that will be copied to your project iOS or Android Project. By default the Info.plist is handled on iOS and the AndroidManifest.xml is handled on Android. For all other platforms you must configure this on your own. You can customize this by configuring any of the following build variables

Build Variable Default Value Platform
BuildResourcesDirectoryName build All
BuildResourcesDirRootPath SolutionDir/BuildResourcesDirectoryName All
ManifestVariablePrefix Manifest_ All
ManifestToken $$ All
InfoPlistTemplateName BuildTemplateInfo.plist iOS
BuildTemplateInfoPlistPath BuildResourcesDirRootPath/InfoPlistTemplateName iOS
InfoPlistPath MSBuildProjectDirectory/Info.plist iOS
TemplateManifestPath BuildTemplateInfoPlistPath iOS
ManifestDestinationPath InfoPlistPath iOS
AndroidManifestTemplateName AndroidTemplateManifest.xml Android
BuildTemplateAndroidManifestPath BuildResourcesDirRootPath/AndroidManifestTemplateName Android
AndroidManifestPath MSBuildProjectDirectory/Properties/AndroidManifest.xml Android
ManifestDestinationPath BuildTemplateAndroidManifestPath Android
TemplateManifestPath AndroidManifestPath Android
ManifestDestinationPath null All Others
TemplateManifestPath null All Others

Putting this all together say that we want to use Mobile Center for Push Notifications and Azure Active Directory with the Microsoft.Identity.Client. This would then require that we expose the Mobile Center App Id and our Azure Active Directory App Client Id in our Info.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleDisplayName</key>
  <string>Awesome App</string>
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLName</key>
      <string>com.prismlib.awesomeapp</string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>msal$$AADClientId$$</string>
      </array>
    </dict>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>mobilecenter-$$MobileCenterSecret$$</string>
      </array>
    </dict>
  </array>
</dict>
</plist>

As you can see from this sample we can protect our client id's by having a Tokenized version of our Info.plist checked into Source Control. We then simply need to add Environment Variables to our CI Build Definition like:

Key Value
Manifest_AADClientId 00000000-0000-0000-0000-000000000000
Manifest_MobileCenterSecret 11111111-1111-1111-1111-111111111111
Clone this wiki locally