Xcode14.2打包时GoogleSignIn SDK签名失败,求兼容Xcode13的方案
解决Xcode14.2打包GoogleSignIn签名问题且兼容Xcode13
方法1:通过Podfile脚本适配不同Xcode版本
在项目的Podfile中添加以下代码,仅针对Xcode14及以上版本自动配置GoogleSignIn的签名信息,Xcode13环境下不会生效:
post_install do |installer| installer.pods_project.targets.each do |target| next unless target.name == 'GoogleSignIn' if Gem::Version.new(Xcode.version) >= Gem::Version.new('14.0') target.build_configurations.each do |config| # 替换为你的开发团队ID config.build_settings['DEVELOPMENT_TEAM'] = 'YOUR_TEAM_ID' # 开启自动签名(可选,根据项目需求调整) config.build_settings['CODE_SIGN_STYLE'] = 'Automatic' end end end end
修改完成后执行pod install,重新安装依赖即可。
方法2:使用xcconfig条件配置文件
- 新建两个配置文件:
Xcode13-Config.xcconfig和Xcode14-Config.xcconfig - 在
Xcode14-Config.xcconfig中添加签名配置:
DEVELOPMENT_TEAM = YOUR_TEAM_ID CODE_SIGN_STYLE = Automatic
- 打开项目的Build Settings,Xcode13环境下选择
Xcode13-Config.xcconfig(保持原有配置即可),Xcode14及以上环境选择Xcode14-Config.xcconfig - 确保GoogleSignIn的target继承项目配置,可在Podfile中设置
inherit! :complete保证配置继承
方法3:手动修改后通过Podfile锁定配置
先在Xcode中打开Pods项目,找到GoogleSignIn target,在Signing & Capabilities中选择开发团队。之后在Podfile中添加以下脚本,防止后续pod install或pod update覆盖你的修改:
post_install do |installer| installer.pods_project.targets.each do |target| next unless target.name == 'GoogleSignIn' if Gem::Version.new(Xcode.version) >= Gem::Version.new('14.0') target.build_configurations.each do |config| config.build_settings['DEVELOPMENT_TEAM'] = 'YOUR_TEAM_ID' config.build_settings['CODE_SIGN_STYLE'] = 'Automatic' end end end end
关键注意点
- 替换
YOUR_TEAM_ID为你实际的开发团队ID,可在Xcode的Signing & Capabilities面板中查看 - 所有方法都保证Xcode13环境下的构建流程不受影响
- 每次执行Pod相关命令后,脚本会自动适配对应Xcode版本的配置
内容的提问来源于stack exchange,提问作者user20220623
相关产品推荐
相关产品推荐

