You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用xcodebuild签名Mac应用报错:配置文件不包含安装证书

问题排查与解决方案

核心问题分析

报错指向配置文件与签名证书不匹配,且Xcode归档正常但xcodebuild失败,主要存在两个关键问题:

1. 归档Scheme选择错误

你当前归档的是TestingToolsExtension(扩展目标)的Scheme,但带扩展的Mac应用必须归档主应用Scheme(应为TestingTools),否则归档文件无法包含主应用与扩展的完整签名配置,直接导致导出阶段证书匹配失败。

2. 签名证书类型不匹配

报错中提到的是3rd Party Mac Developer Installer证书,但你的App-Store.plist里指定的signingCertificate是3rd Party Mac Developer Application证书:

  • 3rd Party Mac Developer Application用于应用代码签名
  • 3rd Party Mac Developer Installer用于安装包签名(导出归档阶段)
    手动签名时需确保证书类型与操作阶段匹配,或改用自动签名简化流程。

具体修复步骤

步骤1:修正归档的Scheme

将归档命令的Scheme改为主应用的Scheme,确保归档包含主应用和扩展的完整目标:

xcodebuild archive \
  -project TestingTools.xcodeproj \
  -scheme TestingTools \  # 替换为主应用Scheme
  -sdk macosx \
  -configuration Release \
  -derivedDataPath DerivedData \
  -archivePath DerivedData/Archive/TestingTools

步骤2:调整Export Options Plist配置

选项A:改用自动签名(推荐,与Xcode行为一致)

既然Xcode归档正常,说明自动签名能正确匹配证书和配置文件,修改App-Store.plist为自动签名模式:

<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>app-store-connect</string>
    <key>teamID</key>
    <string>ZME7ED67F3</string>
    <key>uploadBitcode</key>
    <false/>
    <key>uploadSymbols</key>
    <true/>
    <key>signingStyle</key>
    <string>automatic</string>  <!-- 切换为自动签名 -->
    <!-- 移除手动签名相关的signingCertificate和provisioningProfiles字段 -->
</dict>
</plist>

选项B:保持手动签名并修正证书配置

如果必须使用手动签名,需确保signingCertificate指定安装证书,同时确认配置文件已关联该证书:

<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>app-store-connect</string>
    <key>teamID</key>
    <string>ZME7ED67F3</string>
    <key>uploadBitcode</key>
    <false/>
    <key>uploadSymbols</key>
    <true/>
    <key>signingStyle</key>
    <string>manual</string>
    <key>signingCertificate</key>
    <string>3rd Party Mac Developer Installer: Andrew Brown (ZME7ED67F3)</string>  <!-- 替换为安装证书 -->
    <key>provisioningProfiles</key>
    <dict>
        <key>com.andybrown.TestingTools</key>
        <string>Mac Distribution (Test)</string>
        <key>com.andybrown.TestingTools.TestingToolsExtension</key>
        <string>Testing Tools Extenstion Distribution</string>
    </dict>
</plist>

注意:需确认两个配置文件都已在Apple Developer后台关联3rd Party Mac Developer Installer证书

步骤3:验证配置文件与证书有效性

  1. 打开Xcode,进入Preferences > Accounts,选择你的团队,点击Manage Certificates,确认3rd Party Mac Developer Installer证书存在且未过期
  2. 重新生成并下载最新的分发配置文件:在Apple Developer后台更新两个配置文件,双击导入Xcode后再执行xcodebuild命令

额外验证步骤

执行归档和导出命令前,先清理缓存避免旧配置干扰:

rm -rf DerivedData
xcodebuild clean -project TestingTools.xcodeproj -scheme TestingTools -configuration Release

内容的提问来源于stack exchange,提问作者ADB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 15:35:56