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

Flutter集成solana_wallet_adapter依赖时iOS编译报错求助

Flutter集成solana_wallet_adapter依赖时iOS编译报错求助

大家好,我在给Flutter项目集成solana_wallet_adapter依赖时,iOS端编译遇到了两个棘手的报错,折腾好久都没解决,来求助各位大佬!

报错信息

  • Error: Could not build Objective-C module 'webcrypto' in SwiftWebcryptoPlugin
  • 'Flutter/Flutter.h' file not found in WebcryptoPlugin

我的环境

我使用的是最新稳定版Flutter:

Flutter 3.24.5 • channel stable
Framework • revision dec2ee5c1f (7 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3

Podfile配置

我的iOS项目Podfile内容如下:

# Uncomment this line to define a global platform for your project
platform :ios, '16.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'BoringSSL-GRPC'
      target.source_build_phase.files.each do |file|
        if file.settings && file.settings['COMPILER_FLAGS']
          flags = file.settings['COMPILER_FLAGS'].split
          flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
          file.settings['COMPILER_FLAGS'] = flags.join(' ')
           flutter_additional_ios_build_settings(target)
              target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
                config.build_settings['ENABLE_BITCODE'] = 'NO'
                end
              end
            end
          end
        end
      end

使用的依赖包

我在pubspec.yaml中引入的依赖是:

solana_wallet_adapter: ^0.1.5

已尝试的解决方法

我已经试过下面这些操作,但都没能解决问题:

  • 删除Pods文件夹后重新执行pod install
  • 删除Xcode的Derived Data并重新编译
  • 从pubspec.yaml中移除依赖,执行flutter pub get后再重新添加依赖并同步

有没有大佬遇到过类似的问题?求指点解决办法😭

备注:内容来源于stack exchange,提问作者user16571064

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.15 10:39:35