title: xcodebuild commands failed to generate iPA
body: <p>In xcode 9.2 I'm generating archive using automatic signing, Developer certificate and provisioning profile are generating through xcodebuild commands using <code>-allowProvisioningUpdates</code> key.</p>
  <p>But when generating iPA through xcodebuild commands with that archive getting below error.</p>
  <pre><code>Details:  Unable to close provisioning ledger entry because not all of its subentries are closed
  Object:   &lt;IDEProvisioningLedgerEntry: 0x7f925ced3840&gt;
  Method:   -closeWithError:
  Thread:   &lt;NSThread: 0x7f925a734df0&gt;{number = 4, name = (null)}
  Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
  </code></pre>
  <p>Using Xcodebuild command to generate archive</p>
  <pre><code>xcodebuild -exportArchive -archivePath '/path/to/archive/Test.xcarchive' -exportOptionsPlist '/path/to/exportOptions/ExportOptions.plist' -exportPath '/path/to/archive/' PRODUCT_BUNDLE_IDENTIFIER=&quot;bundle_id&quot; DEVELOPMENT_TEAM=&quot;development_team_id&quot; -allowProvisioningUpdates
  </code></pre>
  <p>And Export plist options details:</p>
  <pre><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;method&lt;/key&gt;
      &lt;string&gt;ad-hoc&lt;/string&gt;
      &lt;key&gt;signingCertificate&lt;/key&gt;
      &lt;string&gt;iPhone Developer&lt;/string&gt;
      &lt;key&gt;signingStyle&lt;/key&gt;
      &lt;string&gt;automatic&lt;/string&gt;
      &lt;key&gt;stripSwiftSymbols&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;teamID&lt;/key&gt;
      &lt;string&gt;TEAM_ID&lt;/string&gt;
      &lt;key&gt;uploadBitcode&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;uploadSymbols&lt;/key&gt;
      &lt;true/&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  <p>Using Xcode GUI all working fine, Developer, Distribution certificate and provisioning profile are generating</p>
  <p>But when using xcodebuild in terminal only developer certificate is generating and developer provisioning profile when archiving. but Distribution certificate is not generating through xcodbuild.</p>
  <p>Can any one help me!</p>