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

安装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:

    1. 在ios目录下创建空的Dummy.swift文件,Xcode会自动生成桥接文件(若未生成可手动创建);
    2. 打开Xcode项目Build Settings,设置Always Embed Swift Standard Libraries为YES,指定Swift Language Version为5.0及以上;
    3. 若使用CocoaPods 1.10+,在Podfile的target块中添加use_frameworks! :linkage => :static,确保Swift框架正确链接。
  • 清理重复链接器标志
    针对-lc++重复问题:

    1. 在Xcode项目Build Settings中搜索Other Linker Flags,移除重复的-lc++条目;
    2. 或在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
      
  • 添加缺失的系统框架
    处理swiftXPC和CoreAudioTypes找不到的问题:

    1. 在Xcode项目的Frameworks, Libraries, and Embedded Content中,点击+搜索并添加CoreAudioTypes.framework(选择Do Not Embed);
    2. 若swiftXPC仍报错,在Build Settings的Framework Search Paths中添加$(SDKROOT)/System/Library/Frameworks,确保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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 02:07:15