<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MacBuildCloud</title>
    <description>The latest articles on DEV Community by MacBuildCloud (@macbuildcloud).</description>
    <link>https://dev.to/macbuildcloud</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4247242%2Fe5a62654-60d7-449c-8021-541ff93a3981.png</url>
      <title>DEV Community: MacBuildCloud</title>
      <link>https://dev.to/macbuildcloud</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/macbuildcloud"/>
    <language>en</language>
    <item>
      <title>Why your CI keeps creating iOS certificates (and how to stop it)</title>
      <dc:creator>MacBuildCloud</dc:creator>
      <pubDate>Tue, 17 Nov 2026 08:09:55 +0000</pubDate>
      <link>https://dev.to/macbuildcloud/why-your-ci-keeps-creating-ios-certificates-and-how-to-stop-it-278e</link>
      <guid>https://dev.to/macbuildcloud/why-your-ci-keeps-creating-ios-certificates-and-how-to-stop-it-278e</guid>
      <description>&lt;p&gt;&lt;em&gt;I'm on the MacBuildCloud team. We run Mac build machines, and this is a bug we shipped into our own pipeline and then took back out. Nothing here depends on our product; every fix below works on GitHub Actions, a self-hosted runner, or any CI that throws its Mac away after each job.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom
&lt;/h2&gt;

&lt;p&gt;Open developer.apple.com, go to &lt;strong&gt;Certificates&lt;/strong&gt;, and look for entries named like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Apple Development: Created via API&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you see one you don't remember making, and especially if you see several, there is a good chance a CI job made them.&lt;/p&gt;

&lt;p&gt;We found ours during our own TestFlight test. The build passed. The &lt;code&gt;.ipa&lt;/code&gt; was fine. Then we checked the team's certificate list and there was a new development certificate that nobody had asked for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;p&gt;Three things combine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The project uses automatic signing.&lt;/strong&gt; That's the Xcode default, so most projects do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The build runs &lt;code&gt;xcodebuild archive&lt;/code&gt; with &lt;code&gt;-allowProvisioningUpdates&lt;/code&gt;&lt;/strong&gt; plus an App Store Connect API key. This is the common advice for "signing without a Mac", and it does work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The build machine is brand new every time.&lt;/strong&gt; A fresh VM or a hosted runner has an empty keychain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;During &lt;code&gt;archive&lt;/code&gt;, automatic signing wants a &lt;em&gt;development&lt;/em&gt; identity on the machine. There isn't one, and &lt;code&gt;-allowProvisioningUpdates&lt;/code&gt; tells Xcode it may fix that. So it generates a private key in the VM's keychain and asks Apple for a new development certificate to match.&lt;/p&gt;

&lt;p&gt;Then the job ends and the VM is deleted, private key and all.&lt;/p&gt;

&lt;p&gt;The certificate is still listed in your account, but nothing anywhere can sign with it any more, because the key that goes with it is gone. The next run starts with an empty keychain again and has the same problem.&lt;/p&gt;

&lt;p&gt;We stopped after the first one, so I can't show you a screenshot of fifty. But nothing about the next run can reuse a certificate whose private key was destroyed. At best you collect clutter that makes it hard to tell which certificate is real. Apple's documentation doesn't publish a number for how many development certificates a team can hold, so I won't guess one; it isn't a pile you want to find out about.&lt;/p&gt;

&lt;p&gt;The CI is also quietly holding a key that can create certificates in your team. Most build jobs don't need that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: don't sign at archive time
&lt;/h2&gt;

&lt;p&gt;This is the change that fixed it for us, and it's small. Archive &lt;strong&gt;without&lt;/strong&gt; signing, then sign once, at export:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xcodebuild \
  -workspace MyApp.xcworkspace -scheme MyApp \
  -destination &lt;span class="s2"&gt;"generic/platform=iOS"&lt;/span&gt; \
  -archivePath build/MyApp.xcarchive \
  &lt;span class="nv"&gt;CODE_SIGNING_ALLOWED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;NO &lt;span class="nv"&gt;CODE_SIGNING_REQUIRED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;NO &lt;span class="nv"&gt;CODE_SIGN_IDENTITY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt; \
  archive

xcodebuild -exportArchive \
  -archivePath build/MyApp.xcarchive \
  -exportOptionsPlist ExportOptions.plist \
  -exportPath build/ipa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The export step needs a distribution certificate and an App Store profile, which is the part you were going to need anyway. No development identity is involved, so there is nothing for Xcode to invent.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExportOptions.plist&lt;/code&gt; is a plain text file you can write on any OS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;plist&lt;/span&gt; &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;method&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;string&amp;gt;&lt;/span&gt;app-store-connect&lt;span class="nt"&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;teamID&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;string&amp;gt;&lt;/span&gt;YOURTEAMID&lt;span class="nt"&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;signingStyle&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;string&amp;gt;&lt;/span&gt;manual&lt;span class="nt"&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;provisioningProfiles&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;com.example.myapp&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&amp;lt;string&amp;gt;&lt;/span&gt;MyApp AppStore&lt;span class="nt"&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/plist&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value under &lt;code&gt;provisioningProfiles&lt;/code&gt; is the profile's name as Apple shows it, not the filename. If the app has extensions (a widget, a share extension, a watch app), each bundle ID needs its own entry and its own profile. Ours had a widget, and a missing widget profile is the error that's easiest to misread, because the message names the extension's bundle ID, not the app's.&lt;/p&gt;

&lt;p&gt;For Flutter it's the same idea: &lt;code&gt;flutter build ipa --no-codesign&lt;/code&gt; (or &lt;code&gt;flutter build ios --no-codesign&lt;/code&gt; plus your own archive step), then &lt;code&gt;-exportArchive&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now you need to get that distribution certificate onto the machine. There are a few honest ways, with different trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option A: a .p12 in your CI secrets
&lt;/h2&gt;

&lt;p&gt;Export your Apple Distribution certificate &lt;strong&gt;with its private key&lt;/strong&gt; as a &lt;code&gt;.p12&lt;/code&gt;, store it as a secret, and import it into a throwaway keychain at the start of each job. GitHub's documentation has a complete example; the core of it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;security create-keychain -p &lt;span class="s2"&gt;"$KEYCHAIN_PASSWORD"&lt;/span&gt; &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
security set-keychain-settings -lut 21600 &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
security unlock-keychain -p &lt;span class="s2"&gt;"$KEYCHAIN_PASSWORD"&lt;/span&gt; &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
security import &lt;span class="nv"&gt;$CERTIFICATE_PATH&lt;/span&gt; -P &lt;span class="s2"&gt;"$P12_PASSWORD"&lt;/span&gt; -A -t cert -f pkcs12 -k &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
security set-key-partition-list -S apple-tool:,apple: -k &lt;span class="s2"&gt;"$KEYCHAIN_PASSWORD"&lt;/span&gt; &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
security list-keychain -d user -s &lt;span class="nv"&gt;$KEYCHAIN_PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then copy the &lt;code&gt;.mobileprovision&lt;/code&gt; into the profiles directory. On a self-hosted runner that is reused between jobs, delete the keychain and the profile at the end, even when the job fails.&lt;/p&gt;

&lt;p&gt;Two things that cost people time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;.p12&lt;/code&gt; has to contain the &lt;strong&gt;private key&lt;/strong&gt;, not just the certificate. In Keychain Access, expand the certificate and select it together with the key underneath before exporting. A &lt;code&gt;.p12&lt;/code&gt; without the key imports without complaint and fails later at &lt;code&gt;codesign&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If the build has two profiles that were both downloaded as &lt;code&gt;profile.mobileprovision&lt;/code&gt;, one can silently overwrite the other. Give them distinct names.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Good for:&lt;/strong&gt; small teams, one app, people who want to see exactly what's happening.&lt;br&gt;
&lt;strong&gt;Trade-off:&lt;/strong&gt; you rotate the &lt;code&gt;.p12&lt;/code&gt; by hand when it expires, and anyone who can read CI secrets can sign as your team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option B: fastlane match
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;match&lt;/code&gt; keeps your certificates and profiles encrypted in a private git repo (or a Google Cloud or S3 bucket) and installs them on each machine. Its documentation recommends running it in &lt;code&gt;readonly&lt;/code&gt; mode on CI, so CI can fetch certificates but never create or revoke them. The &lt;code&gt;setup_ci&lt;/code&gt; action creates a temporary keychain and switches &lt;code&gt;match&lt;/code&gt; to read-only for you.&lt;/p&gt;

&lt;p&gt;I haven't run &lt;code&gt;match&lt;/code&gt; in our pipeline, so I'll leave the details to its docs. The point that matters here: &lt;strong&gt;&lt;code&gt;readonly&lt;/code&gt; on CI is exactly the rule this whole post is about.&lt;/strong&gt; The machine that gets destroyed is never the one that creates certificates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good for:&lt;/strong&gt; teams with several developers and several apps.&lt;br&gt;
&lt;strong&gt;Trade-off:&lt;/strong&gt; one more tool and one more encrypted store to look after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option C: Apple's cloud signing
&lt;/h2&gt;

&lt;p&gt;Since Xcode 13, Apple can sign distribution builds with a &lt;strong&gt;cloud-managed certificate&lt;/strong&gt;: the private key stays with Apple, not on your machine. In CI this means giving &lt;code&gt;xcodebuild&lt;/code&gt; an App Store Connect API key and &lt;code&gt;-allowProvisioningUpdates&lt;/code&gt; at &lt;strong&gt;export&lt;/strong&gt; time. Nesim Razon describes this setup in a recent DEV post about shipping a Kotlin Multiplatform app from Windows; in that write-up an App Manager key wasn't enough for cloud signing and an Admin key was.&lt;/p&gt;

&lt;p&gt;We haven't tested this path ourselves, so two things to check if you use it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep &lt;code&gt;archive&lt;/code&gt; unsigned (Fix 1). Cloud signing covers distribution, but an automatically signed &lt;code&gt;archive&lt;/code&gt; on a fresh machine can still go looking for a development identity, and that's where our stray certificate came from.&lt;/li&gt;
&lt;li&gt;An Admin-role key can do a lot more than sign. Weigh that against storing a &lt;code&gt;.p12&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Good for:&lt;/strong&gt; people with no Mac at all who don't want to handle a &lt;code&gt;.p12&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Trade-off:&lt;/strong&gt; a high-privilege key lives in CI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option D: don't sign in CI
&lt;/h2&gt;

&lt;p&gt;Build with &lt;code&gt;CODE_SIGNING_ALLOWED=NO&lt;/code&gt; and sign on a machine you control. You still get compilation, tests and artifacts from CI, and your signing identity never leaves your laptop. If you have a Mac and ship once a week, this is a perfectly good answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleaning up what's already there
&lt;/h2&gt;

&lt;p&gt;On developer.apple.com, &lt;strong&gt;Certificates&lt;/strong&gt;, look at the development certificates named "Created via API" and check the dates against your CI history. Apple's docs say that any provisioning profile containing a revoked certificate becomes invalid, so before revoking, make sure no development profile you still use on your own machine includes it. Revoking stray &lt;em&gt;development&lt;/em&gt; certificates doesn't touch apps already on the App Store, which are signed with your distribution certificate.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule we took away
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A machine that is destroyed after the job should never be allowed to create anything in your Apple account.&lt;/strong&gt; Credentials go in read-only; nothing comes out. Our check now isn't "did this build pass", it's "did the certificate count stay the same". A build that passes while it leaves something behind in a third-party account is the hardest kind of bug to notice.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This article was written with the help of AI and checked against our own build logs and the official Apple, GitHub and fastlane documentation.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>devops</category>
      <category>cicd</category>
      <category>xcode</category>
    </item>
  </channel>
</rss>
