Fastlane gym返回65错误:Flutter iOS TestFlight部署失败
问题:Github Action + Fastlane Match 构建Flutter iOS应用到TestFlight失败(错误码65)
更换笔记本后忘记钥匙串密码,用match清空并重新生成所有证书和配置文件,match环节看似正常,但构建阶段报错误码65,无明确报错信息。
相关Fastlane Lane代码
platform :ios do lane :closed_beta do setup_ci(verbose: true) match( type: 'appstore', app_identifier: "#{BUNDLE_IDENTIFIER}", git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTH_TOKEN"]), readonly: true, verbose: true, ) build_app( scheme: "Runner", export_method: "app-store", verbose: true, ) pilot( apple_id: "#{APPLICATON_ID}", app_identifier: "#{BUNDLE_IDENTIFIER}", skip_waiting_for_build_processing: true, skip_submission: true, distribute_external: false, notify_external_testers: false, ipa: "./Runner.ipa", itc_provider: "CN7XB83K76" ) end end
构建失败日志
INFO [2023-02-15 14:22:09.12]: ▸ ** ARCHIVE FAILED ** Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner') Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner') Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner') ** ARCHIVE FAILED ** ERROR [2023-02-15 14:22:09.14]: Exit status: 65 INFO [2023-02-15 14:22:09.15]:
Match环节相关日志(疑似异常)
INFO [2023-02-15 14:21:44.80]: ▸ "/Users/runner/Library/Keychains/fastlane_tmp_keychain-db" DEBUG [2023-02-15 14:21:44.80]: Installing WWDR Cert: curl -f -o /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/AppleWWDRCAG6.cer20230215-42299-x0khh8 https://www.apple.com/certificateauthority/AppleWWDRCAG6.cer && security import /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/AppleWWDRCAG6.cer20230215-42299-x0khh8 -k /Users/runner/Library/Keychains/fastlane_tmp_keychain-db INFO [2023-02-15 14:21:45.15]: ▸ 1 certificate imported. INFO [2023-02-15 14:21:45.15]: ▸ 100 794 100 794 0 0 2688 0 --:--:-- --:--:-- --:--:-- 2719 ERROR [2023-02-15 14:21:45.22]: There are no local code signing identities found. You can run `security find-identity -v -p codesigning fastlane_tmp_keychain` to get this output. This Stack Overflow thread has more information: https://stackoverflow.com/q/35390072/774. (Check in Keychain Access for an expired WWDR certificate: https://stackoverflow.com/a/35409835/774 has more info.) INFO [2023-02-15 14:21:45.30]: $ security import /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/d20230215-42299-tdvo05/certs/distribution/PY2SL32M49.cer -k '/Users/runner/Library/Keychains/fastlane_tmp_keychain-db' -P ******** -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productbuild -T /usr/bin/productsign INFO [2023-02-15 14:21:45.39]: ▸ 1 certificate imported. INFO [2023-02-15 14:21:45.40]: Setting key partition list... (this can take a minute if there are a lot of keys installed) INFO [2023-02-15 14:21:45.40]: $ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ******** /Users/runner/Library/Keychains/fastlane_tmp_keychain-db 1> /dev/null ERROR [2023-02-15 14:21:45.44]: security: SecItemCopyMatching: The specified item could not be found in the keychain. INFO [2023-02-15 14:21:45.44]: $ security import /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/d20230215-42299-tdvo05/certs/distribution/PY2SL32M49.p12 -k '/Users/runner/Library/Keychains/fastlane_tmp_keychain-db' -P ******** -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productbuild -T /usr/bin/productsign INFO [2023-02-15 14:21:45.54]: ▸ 1 key imported.
解决方案
从日志看,核心问题是代码签名身份未正确加载,结合match重新生成证书的操作,按以下步骤排查:
调整match只读模式
当前lane中match使用readonly: true,但刚重新生成证书,需先以非只读模式运行一次match,确保新证书同步到Git仓库:match( type: 'appstore', app_identifier: "#{BUNDLE_IDENTIFIER}", git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTH_TOKEN"]), readonly: false, # 临时改为false verbose: true, )本地运行完成后,改回
readonly: true用于CI环境。修复钥匙串权限配置
日志中出现钥匙串项找不到的错误,在setup_ci后添加手动设置权限的命令:setup_ci(verbose: true) # 添加以下命令,确保MATCH_PASSWORD已在Github Action环境变量中配置 sh("security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k #{ENV['MATCH_PASSWORD']} #{ENV['FASTLANE_TEMP_KEYCHAIN']}")验证签名身份存在性
在build_app前添加验证命令,确认签名身份已正确导入:sh("security find-identity -v -p codesigning #{ENV['FASTLANE_TEMP_KEYCHAIN']}")若输出为空,需检查match的Git仓库是否包含最新证书文件。
清理构建缓存
在构建前添加Flutter清理步骤,避免旧缓存干扰:flutter_clean检查Xcode签名配置
确保Xcode项目中Runnertarget的签名设置为「Automatic」,让Fastlane自动匹配证书,不要手动指定签名身份。
内容的提问来源于stack exchange,提问作者alexlipa
相关产品推荐
相关产品推荐

