title: xcodebuild strips CFBundleVersion and CFBundleShortVersionString from Info.plist
body: <p>I am building an iOS app in Azure DevOps. The build and export of the *.ipa works fine, but the upload to the App Store fails with the following message:</p>
  <pre><code>2020-10-05T14:02:27.9260830Z [14:02:27]: [Transporter Error Output]: ERROR ITMS-90057: &quot;The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring&quot;
  2020-10-05T14:02:27.9268950Z [14:02:27]: [Transporter Error Output]: ERROR ITMS-90056: &quot;This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion&quot;
  2020-10-05T14:02:28.1474570Z [14:02:28]: Transporter transfer failed.
  2020-10-05T14:02:28.1475590Z [14:02:28]: 
  2020-10-05T14:02:28.1477810Z [14:02:28]: ERROR ITMS-90057: &quot;The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring&quot;
  2020-10-05T14:02:28.1480380Z ERROR ITMS-90056: &quot;This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion&quot;
  2020-10-05T14:02:28.2737090Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] &lt;main&gt; DBG-X:   parameter ShouldUseRESTAPIs = false
  2020-10-05T14:02:28.2741670Z 
  2020-10-05T14:02:28.2743710Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] &lt;main&gt; ERROR: ERROR ITMS-90057: &quot;The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring&quot;
  2020-10-05T14:02:28.2745220Z 
  2020-10-05T14:02:28.2746740Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] &lt;main&gt; ERROR: ERROR ITMS-90056: &quot;This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion&quot;
  2020-10-05T14:02:28.2747600Z 
  2020-10-05T14:02:28.2748330Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] &lt;main&gt; DBG-X: The error code is: 1102
  2020-10-05T14:02:28.2748700Z 
  2020-10-05T14:02:28.2749420Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:27 UTC] &lt;main&gt;  INFO: Done performing authentication.
  2020-10-05T14:02:28.2749760Z 
  2020-10-05T14:02:28.2749950Z [14:02:28]: [iTMSTransporter] 
  2020-10-05T14:02:28.2750120Z 
  2020-10-05T14:02:28.2750310Z [14:02:28]: [iTMSTransporter] 
  2020-10-05T14:02:28.2750480Z 
  2020-10-05T14:02:28.2750660Z [14:02:28]: [iTMSTransporter] 
  2020-10-05T14:02:28.2750830Z 
  2020-10-05T14:02:28.2751070Z [14:02:28]: [iTMSTransporter] Package Summary:
  2020-10-05T14:02:28.2751270Z 
  2020-10-05T14:02:28.2751460Z [14:02:28]: [iTMSTransporter]  
  2020-10-05T14:02:28.2751630Z 
  2020-10-05T14:02:28.2751950Z [14:02:28]: [iTMSTransporter] 1 package(s) were not uploaded because they had problems:
  2020-10-05T14:02:28.2752240Z 
  2020-10-05T14:02:28.2753070Z [14:02:28]: [iTMSTransporter]  /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/d20201005-1299-rww8bj/1454404673.itmsp - Error Messages:
  2020-10-05T14:02:28.2753450Z 
  2020-10-05T14:02:28.2754860Z [14:02:28]: [iTMSTransporter]      ERROR ITMS-90057: &quot;The bundle 'Payload/MyApp.app' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring&quot;
  2020-10-05T14:02:28.2755720Z 
  2020-10-05T14:02:28.2757000Z [14:02:28]: [iTMSTransporter]      ERROR ITMS-90056: &quot;This bundle Payload/MyApp.app is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion&quot;
  2020-10-05T14:02:28.2757770Z 
  2020-10-05T14:02:28.2758440Z [14:02:28]: [iTMSTransporter] [2020-10-05 14:02:28 UTC] &lt;main&gt; DBG-X: Returning 1
  </code></pre>
  <p>Sure enough, when I extract the ipa file and look in &quot;Payload/MyApp.app/Info.plist&quot;, <code>CFBundleVersion</code> and <code>CFBundleShortVersionString</code> are missing.</p>
  <p>However, those values are included in the original, pre-compilation Info.plist and are also set during the build phase using GitVersion and PlistBuddy. I have checked that the variables are correctly set and also tried to just use the hard-coded versions, which did not change the result.</p>
  <pre class="lang-sh prettyprint-override"><code>&gt; echo 'iOsBundleVersion: $(iOsBundleVersion)'
  iOsBundleVersion: 1.2.21
  &gt; echo 'iOsMarketingVersion: $(iOsMarketingVersion)'
  iOsMarketingVersion: 1.2
  
  </code></pre>
  <h2>azure-pipelines.yml (extract):</h2>
  <pre class="lang-yaml prettyprint-override"><code>- task: InstallAppleCertificate@2
    displayName: 'Install certificates'
    inputs:
      certSecureFile: $(certSecureFile)
      certPwd: '$(certPwd)'
      keychain: 'temp'
  
  - task: InstallAppleProvisioningProfile@1
    displayName: 'Install provisioning profile'
    inputs:
      provisioningProfileLocation: 'secureFiles'
      provProfileSecureFile: $(provProfileSecureFile)
  
  - task: CocoaPods@0
    displayName: 'Install CocoaPods'
    inputs:
      workingDirectory: '$(appRoot)'
      forceRepoUpdate: true
      projectDirectory: 'ios'
  
  - task: Bash@3
    displayName: 'Set bundle version'
    inputs:
      targetType: 'inline'
      script: |
        /usr/libexec/PlistBuddy -c &quot;Set CFBundleVersion $(iOsBundleVersion)&quot; ./Info.plist
        /usr/libexec/PlistBuddy -c &quot;Set CFBundleShortVersionString $(iOsMarketingVersion)&quot; ./Info.plist
      workingDirectory: '$(appRoot)'
  
  - task: Xcode@5
    displayName: 'Build project'
    inputs:
      actions: 'archive'
      configuration: 'Release'
      sdk: 'iphoneos'
      xcWorkspacePath: '$(appRoot)/MyApp.xcworkspace'
      scheme: '$(appName)'
      packageApp: true
      exportPath: '$(appRoot)/ios/build'
      xcodeVersion: 'default'
      signingOption: 'manual'
      signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
      provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
      args: '-UseModernBuildSystem=0'
      workingDirectory: '$(appRoot)'
      useXcpretty: true
  </code></pre>
  <p>which results in the following commands:</p>
  <pre class="lang-sh prettyprint-override"><code>xcodebuild -workspace /Users/runner/work/1/s/MyApp.xcworkspace -scheme MyApp archive -sdk iphoneos -configuration Release -archivePath /Users/runner/work/1/s/MyApp CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=Apple Distribution: xxxxxxxx (xxxxxxxxx) PROVISIONING_PROFILE=xxxxxxxx PROVISIONING_PROFILE_SPECIFIER= -UseModernBuildSystem=0 | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty --no-color
  </code></pre>
  <p>and</p>
  <pre class="lang-sh prettyprint-override"><code>xcodebuild -exportArchive -archivePath /Users/runner/work/1/s/MyApp.xcarchive -exportPath /Users/runner/work/1/s/ios/build -exportOptionsPlist _XcodeTaskExportOptions.plist | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty --no-color
  </code></pre>
  <h2>Info.plist (extract):</h2>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
      &lt;key&gt;CFBundleDevelopmentRegion&lt;/key&gt;
      &lt;string&gt;en&lt;/string&gt;
      &lt;key&gt;CFBundleDisplayName&lt;/key&gt;
      &lt;string&gt;$(PRODUCT_NAME)&lt;/string&gt;
      &lt;key&gt;CFBundleExecutable&lt;/key&gt;
      &lt;string&gt;$(EXECUTABLE_NAME)&lt;/string&gt;
      &lt;key&gt;CFBundleIdentifier&lt;/key&gt;
      &lt;string&gt;$(PRODUCT_BUNDLE_IDENTIFIER)&lt;/string&gt;
      &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt;
      &lt;string&gt;6.0&lt;/string&gt;
      &lt;key&gt;CFBundleName&lt;/key&gt;
      &lt;string&gt;$(PRODUCT_NAME)&lt;/string&gt;
      &lt;key&gt;CFBundlePackageType&lt;/key&gt;
      &lt;string&gt;APPL&lt;/string&gt;
      &lt;key&gt;CFBundleShortVersionString&lt;/key&gt;
      &lt;string&gt;1.2&lt;/string&gt;
      &lt;key&gt;CFBundleSignature&lt;/key&gt;
      &lt;string&gt;????&lt;/string&gt;
      &lt;key&gt;CFBundleVersion&lt;/key&gt;
      &lt;string&gt;1.2.20&lt;/string&gt;
      &lt;key&gt;ITSAppUsesNonExemptEncryption&lt;/key&gt;
      &lt;false/&gt;
      &lt;key&gt;LSApplicationCategoryType&lt;/key&gt;
      &lt;string&gt;public.app-category.utilities&lt;/string&gt;
      &lt;key&gt;LSRequiresIPhoneOS&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
  </code></pre>