安装react-native-smartlook-analytics后Expo SDK50的EAS iOS构建失败求助
解决安装react-native-smartlook-analytics后EAS构建iOS失败的链接器错误
问题描述
安装react-native-smartlook-analytics包后,EAS构建iOS项目在Linking步骤后失败,报错信息如下:
ld: ignoring duplicate libraries: '-lc++'
⚠️ ld: Could not find or use auto-linked library 'swiftXPC': library 'swiftXPC' not found
⚠️ ld: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
❌ ld: Undefined symbols:
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决方案
配置Swift环境支持
SmartLook依赖Swift,需确保iOS项目适配Swift:- 在
ios目录下创建空的Dummy.swift文件,Xcode会自动生成桥接文件(若未生成可手动创建); - 打开Xcode项目Build Settings,设置
Always Embed Swift Standard Libraries为YES,指定Swift Language Version为5.0及以上; - 若使用CocoaPods 1.10+,在
Podfile的target块中添加use_frameworks! :linkage => :static,确保Swift框架正确链接。
- 在
清理重复链接器标志
针对-lc++重复问题:- 在Xcode项目Build Settings中搜索
Other Linker Flags,移除重复的-lc++条目; - 或在
Podfile中添加post_install钩子自动去重:post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['OTHER_LDFLAGS'] = config.build_settings['OTHER_LDFLAGS'].uniq end end end
- 在Xcode项目Build Settings中搜索
添加缺失的系统框架
处理swiftXPC和CoreAudioTypes找不到的问题:- 在Xcode项目的
Frameworks, Libraries, and Embedded Content中,点击+搜索并添加CoreAudioTypes.framework(选择Do Not Embed); - 若
swiftXPC仍报错,在Build Settings的Framework Search Paths中添加$(SDKROOT)/System/Library/Frameworks,确保Xcode能定位系统框架。
- 在Xcode项目的
清理缓存并重新构建
执行以下命令彻底清理旧配置:rm -rf node_modules && npm install cd ios && pod deintegrate && pod install && cd .. eas build --clear-cache验证版本兼容性
确认react-native-smartlook-analytics版本与当前React Native版本匹配,查看包文档后升级或降级至兼容版本。
内容的提问来源于stack exchange,提问作者basem abdelmalek
相关产品推荐
相关产品推荐

