使用 OneSignal 的 Flutter ios 应用程序无法 build/archive,错误 'OneSignal/OneSignal.h' 文件未找到

Flutter ios app with OneSignal failing to build/archive with error 'OneSignal/OneSignal.h' file not found

我已经多次得到

OneSignal.h not found

尝试存档我的 iOS flutter 应用程序时出错。我已经使用模拟器在我的 IntelliJ 环境中成功构建了应用程序,但无法在 XCode 中构建它。我尝试了几个旧的解决方案,想知道这是否是新版本

的新问题

onesignal_flutter

包。它在 OneSignalNotificationExtention 目标上失败。这是我的 PodFile....

# Uncomment this line to define a global platform for your project
 platform :ios, '12.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

def flutter_install_ios_plugin_pods(ios_application_path = nil)
  ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
  raise 'Could not find iOS application path' unless ios_application_path

  symlink_dir = File.expand_path('.symlinks', ios_application_path)
  system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils.

  symlink_plugins_dir = File.expand_path('plugins', symlink_dir)
  system('mkdir', '-p', symlink_plugins_dir)

  plugins_file = File.join(ios_application_path, '..', '.flutter-plugins-dependencies')
  plugin_pods = flutter_parse_plugins_file(plugins_file)
  plugin_pods.each do |plugin_hash|
    plugin_name = plugin_hash['name']
    plugin_path = plugin_hash['path']
    if (plugin_name && plugin_path)
      symlink = File.join(symlink_plugins_dir, plugin_name)
      File.symlink(plugin_path, symlink)

      if plugin_name == 'flutter_ffmpeg'
          pod 'flutter_ffmpeg/full-lts', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
      else
          pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
      end
    end
  end
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  pod 'FBSDKCoreKit', '~> 11.2.0'
  pod 'FBSDKShareKit', '~> 11.2.0'
  pod 'FBSDKShareKit', '~> 11.2.0'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 3.4.3', '< 4.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

这是依赖错误。有时会发生这种情况,因为您的依赖项没有完全加载到您的项目中并且遗漏了一些东西。尝试 Flutter clean 然后 Flutter pub get 几次,这个错误就会消失。如果不是这样,请尝试 flutter clean,然后在 ios 目录中尝试 flutter pub get 和 pod install,这将解决问题。我希望这对你有用!