Expo + React Native iOS生产构建失败:BoringSSL-GRPC目标存在不支持的'-G'选项错误
Expo + React Native iOS生产构建失败:BoringSSL-GRPC目标存在不支持的'-G'选项错误
我完全懂你现在的烦躁——用eas build --platform ios --profile production构建生产包时,反复被BoringSSL-GRPC的unsupported option '-G'错误卡壳,手动改Podfile也没见效,这问题确实棘手。
问题根源
这个错误是因为某个依赖(大概率是gRPC相关的库)在自动注入编译参数时,给BoringSSL-GRPC目标加上了iOS 15.1 arm64架构不支持的-G编译选项,而你现有Podfile里的清理逻辑可能没精准覆盖到这个目标的参数处理。
针对性修复方案
你需要调整Podfile里post_install钩子中针对BoringSSL-GRPC的配置逻辑,彻底清除-G选项,同时确保自定义的编译参数正确生效。把你现有的BoringSSL-GRPC配置部分替换成下面的代码:
# 针对BoringSSL-GRPC的特殊处理:彻底清除无效的-G选项并设置正确编译参数 if target.name == 'BoringSSL-GRPC' # 先完全重置OTHER_CFLAGS和OTHER_CPLUSPLUSFLAGS,避免残留无效参数 config.build_settings['OTHER_CFLAGS'] = '$(inherited) -Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations -Wno-ignored-attributes -Wno-unused-variable -Wno-unused-function -Wno-unused-const-variable -Wno-unused-parameter -Wno-unused-private-field -Wno-unused-value -Wno-unused-result' config.build_settings['OTHER_CPLUSPLUSFLAGS'] = '$(inherited) -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_STD_RESULT_OF=0 -DFOLLY_HAVE_STD_STRING_VIEW=0' # 二次检查并移除任何可能残留的-G选项 if config.build_settings['OTHER_CFLAGS']&.include?('-G') config.build_settings['OTHER_CFLAGS'] = config.build_settings['OTHER_CFLAGS'].gsub(/\s*-G\s*/, ' ').strip end if config.build_settings['OTHER_CPLUSPLUSFLAGS']&.include?('-G') config.build_settings['OTHER_CPLUSPLUSFLAGS'] = config.build_settings['OTHER_CPLUSPLUSFLAGS'].gsub(/\s*-G\s*/, ' ').strip end end
额外排查建议
- 确认构建环境Xcode版本:在
eas.json的production profile里指定兼容iOS 15.1的Xcode版本(比如Xcode 14.3.1,它对iOS 15+的支持更稳定) - 清理本地缓存后重试:本地先执行
npx pod-install --clean-install清除旧Pods依赖,再重新触发EAS构建 - 检查依赖版本:确保你的Firebase、gRPC相关依赖的版本和Expo/React Native版本兼容
内容来源于stack exchange
相关产品推荐
相关产品推荐

