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

Flutter项目集成RevenueCat插件编译报错,满足版本要求仍无法构建

解决RevenueCat编译报错:"RevenueCat requires Xcode 13.2 with Swift 5.5.2 to compile"

以下是针对你的环境的可行修复步骤:

1. 检查并更新RevenueCat插件版本

旧版本的RevenueCat可能对高版本Xcode/Swift的兼容性处理有问题,先确保你用的是最新稳定版:

  • 在pubspec.yaml中更新purchases_flutter到最新版,比如:
    dependencies:
      purchases_flutter: ^6.0.0 # 替换为当前最新版本
    
  • 执行命令更新依赖:
    flutter pub get
    

2. 配置Xcode项目的Swift版本和部署目标

虽然你的Swift版本是5.7.2,但项目可能强制使用了更低的版本:

  • 打开Flutter项目的iOS目录(ios/Runner.xcworkspace)
  • 选中Runner目标,进入Build Settings
  • 找到Swift Language Version,确保设置为Swift 5(或更高,匹配你的Xcode版本)
  • 检查iOS Deployment Target,设置为至少13.0(RevenueCat的最低要求)

3. 清理Xcode缓存和Flutter构建缓存

缓存冲突可能导致版本检测异常:

  • 清理Flutter缓存:
    flutter clean
    rm -rf ios/Pods ios/Podfile.lock
    rm -rf ~/Library/Caches/CocoaPods
    rm -rf ios/Runner.xcworkspace
    
  • 重新安装Pods:
    cd ios
    pod install
    cd ..
    
  • 重启Xcode,然后尝试重新构建

4. 检查Xcode命令行工具版本

确保Xcode命令行工具和你安装的Xcode版本一致:

  • 打开终端执行:
    xcode-select -p
    
  • 如果输出不是/Applications/Xcode.app/Contents/Developer,执行:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    
  • 验证版本:
    xcodebuild -version
    
    确认输出的Xcode版本是14.2,Swift版本是5.7.2

5. 手动指定Pod的Swift版本(如果上述步骤无效)

在iOS目录的Podfile中添加以下配置,强制所有Pods使用Swift5:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5'
    end
  end
end

然后重新执行pod install


内容的提问来源于stack exchange,提问作者Mahmoud Haj Ali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 14:25:15