專案換憑證
如果電腦上有可以用的發布憑證,可能是 App Profile 對應到的不是你電腦上這張有私鑰的憑證 App Profile 只是設定一張憑證,所以多人開發需要統一使用同一張憑證 如果遺失或過期就需要重建新憑證並更新 App Profile 對應憑證設定 建立後需要使用 Keychain 將憑證匯出 p12 格式,並設定密碼,才能匯入到其他電腦上
重建 Apple Distribution 憑證 (Distribution Certificate)
⸻
🔹 一、先檢查並清除舊憑證
打開 Mac 的鑰匙圈存取 (Keychain Access) • 找到 Apple Distribution 憑證 (通常是「憑證」+「私鑰」兩個一組)。 • 如果這張憑證已經過期或壞掉,建議整組刪掉。
Apple Developer Console 檢查 • 進入 Apple Developer → Certificates, Identifiers & Profiles • 在 Certificates 裡面找到舊的 Apple Distribution 憑證。 • 如果它壞掉或已經沒用,可以直接刪除。
⸻
🔹 二、建立新的 Distribution 憑證
有兩種方式:
方式 A:用 Xcode 自動產生 (最簡單)
打開你的專案 → 選擇 Target → Signing & Capabilities
勾選 Automatically manage signing
選擇正確的 Team
Xcode 會自動替你建立新的 Apple Distribution 憑證並安裝到 Keychain。
⸻
方式 B:手動建立 (進階)
產生 CSR 檔 • 打開 鑰匙圈存取 → 憑證輔助程式 → 從憑證授權機構要求憑證… • 輸入你的 Apple ID Email & Common Name,儲存成 .certSigningRequest (CSR) 檔案。
上傳 CSR 並建立憑證 • 進入 Apple Developer Certificates • 按 + → 選擇 Apple Distribution → Upload CSR → 下載 .cer 憑證。
安裝憑證 • 下載下來的 .cer 憑證雙擊,它會自動安裝到 Keychain,跟你的私鑰綁在一起。
⸻
🔹 三、更新 Provisioning Profile
新的 Distribution 憑證建立後,你的 Provisioning Profile 要重新產生: • 進入 Apple Developer → Profiles → 找到 App 對應的 Profile。 • 重新編輯並勾選新的 Apple Distribution 憑證,然後重新下載。 • Xcode 會自動抓取最新的 Profile。
⸻
🔹 四、重新編譯 & 發佈
在 Xcode Product → Archive
用新的 Distribution 憑證進行 Distribute App
上傳到 App Store Connect。
⸻
⚠️ 注意事項: • 每個 Apple 開發者帳號最多同時存在 3 張 Apple Distribution 憑證。如果滿了,要刪掉舊的才能重建。
• 建議只用 一個 Mac 建立憑證,其他人用 Xcode 就能同步下載,不要每個人都建一張。
⸻