Flutter误差:Swift编译器错误(Xcode):在框架模块“FirebaseSessions. FIRSESNanoPBHelpers”中包含非模块化头:

hmmo2u0o  于 2023-03-31  发布在  Flutter
关注(0)|答案(3)|浏览(331)

错误

在IOS 14上运行flutter时显示此错误消息

Swift Compiler Error (Xcode): Include of non-modular header inside framework module 'FirebaseSessions.FIRSESNanoPBHelpers':
           '/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/Headers/Public/nanopb/pb.h'

/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/FirebaseSessions/FirebaseSessions/SourcesObjC/NanoPB/FIRSE
           SNanoPBHelpers.h:28:8
           
[   +4 ms] Swift Compiler Error (Xcode): Include of non-modular header inside framework module 'FirebaseSessions.FIRSESNanoPBHelpers':
           '/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/Headers/Public/nanopb/pb_decode.h'

/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/FirebaseSessions/FirebaseSessions/SourcesObjC/NanoPB/FIRSE
           SNanoPBHelpers.h:29:8
           
[        ] Swift Compiler Error (Xcode): Include of non-modular header inside framework module 'FirebaseSessions.FIRSESNanoPBHelpers':
           '/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/Headers/Public/nanopb/pb_encode.h'

/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/FirebaseSessions/FirebaseSessions/SourcesObjC/NanoPB/FIRSE
           SNanoPBHelpers.h:30:8
           
[        ] Swift Compiler Error (Xcode): Include of non-modular header inside framework module 'FirebaseSessions.sessions_nanopb':
           '/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/Headers/Public/nanopb/pb.h'

/Users/azzura/Documents/Projects/Self-Learn/flutter-dev/flutter_financial/ios/Pods/FirebaseSessions/FirebaseSessions/SourcesObjC/Protogen/nan
           opb/sessions.nanopb.h:21:9
           
[        ] Swift Compiler Error (Xcode): Could not build Objective-C module 'FirebaseSessions'
           
[   +3 ms] Could not build the application for the simulator.
[   +1 ms] Error launching application on iPhone 14 Pro Max.

Podfile

这是我播客文件,我应该改变我如何放置“Firebase”吗?

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

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

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

pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
$RNFirebaseAsStaticFramework = true

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!

  pod 'BoringSSL-GRPC'

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
    end
  end
end

我试着删除pubspec.lock,ios中的Pods文件夹和Podfile.lock然后运行flutter clean -〉flutter pub get -〉cd ios -〉pod install -〉cd.. -〉flutter run,但它仍然不起作用

j8yoct9x

j8yoct9x1#

最新版本的Firebase需要use_frameworks!(或Podfile中的use_frameworks! :linkage => :static。不再支持use_modular_headers!

gzjq41n4

gzjq41n42#

按照Paul的建议进行了上述更改,在pod文件中将use_frameworks!更改为use_frameworks! :linkage => :static并注解掉use_modular_headers!,但仍然面临相同的错误。
像这样在pod文件中更新

target 'Runner' do
  use_frameworks! :linkage => :static

对此,有没有更新的解决方案?

njthzxwz

njthzxwz3#

发现了这一点,但不知道在哪里以及如何实现它。
https://github.com/invertase/firestore-ios-sdk-frameworks/issues/59
尝试在
ios〉Pod〉本地播客规格〉Firebase Firestore.podspec.json
但是在上面的参考链接中,文件不是json,我试图以json格式进行更改,但每次运行build时,更改都会消失。
会很感激你的帮助。

相关问题