首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >致命错误:2022年未找到#import <Flutter/Flutter.h>文件

致命错误:2022年未找到#import <Flutter/Flutter.h>文件
EN

Stack Overflow用户
提问于 2022-02-16 06:27:38
回答 2查看 288关注 0票数 0

在过去的三天里,我使用了很多很多的解决方案,但是我仍然无法摆脱这个问题,请帮助我。

代码语言:javascript
运行
复制
Xcode's output:
↳
In file included from 
/Users/hxtreme/Desktop/MobileApp/flutter/.pub- 
cache/hosted/pub.dartlang.org/wakelock- 
0.5.6/ios/Classes/WakelockPlugin.m:1:
/Users/hxtreme/Desktop/MobileApp/flutter/.pub- 
cache/hosted/pub.dartlang.org/wakelock- 
0.5.6/ios/Classes/WakelockPlugin.h:1:9: fatal error: 
'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro.

我使用的是颤振v2.8.1,我也尝试了不同的版本,如v2.5.1,v2.10.1,但没有使用.也尝试过各种堆叠溢出解决方案,但没有帮到我。

POD文件:

代码语言:javascript
运行
复制
# Uncomment this line to define a global platform for your project
platform :ios, '15.2'

# 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__))
end

post_install do |installer|
  installer.pods_project.frameworks_group["iOS"]["MobileCoreServices.framework"].remove_from_project
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.2'
    end
  end
end

提前谢谢!

在以下解决方案完成后出现新的错误

代码语言:javascript
运行
复制
/Users/hxtreme/Desktop/MobileApp/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_ffmpeg-0.4.2/ios/Classes/FlutterExecuteDelegate.h:21:9: fatal error: 'mobileffmpeg/ExecuteDelegate.h' file not found
    #import <mobileffmpeg/ExecuteDelegate.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
In file included from /Users/hxtreme/Desktop/MobileApp/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_ffmpeg-0.4.2/ios/Classes/EmptyLogDelegate.m:20:
/Users/hxtreme/Desktop/MobileApp/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_ffmpeg-0.4.2/ios/Classes/EmptyLogDelegate.h:20:10: fatal error: 'mobileffmpeg/LogDelegate.h' file not found
    #include <mobileffmpeg/LogDelegate.h>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/hxtreme/Desktop/MobileApp/bemeli_app/ios/Pods/Pods.xcodeproj: warning: MobileCoreServices has been renamed. Use CoreServices instead. (in target 'GCDWebServer' from project 'Pods')
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro.
EN

回答 2

Stack Overflow用户

发布于 2022-02-16 06:51:15

更改您的Podfile

来自这个

代码语言:javascript
运行
复制
post_install do |installer|
  installer.pods_project.frameworks_group["iOS"]["MobileCoreServices.framework"].remove_from_project
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.2'
    end
  end
end

到此

代码语言:javascript
运行
复制
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
票数 0
EN

Stack Overflow用户

发布于 2022-02-17 07:05:14

要解决该错误,请继续执行以下步骤:

运行程序备份运行程序directory

  • Delete ios目录

  • 转到终端并执行颤振项目文件夹中的flutter create .

  • 将您的Runner文件夹粘贴回ios directory

  • pod install中的ios directory

  • pod deintegrate中,也在flutter项目directory

  • flutter pub get

  • flutter run

中的ios directory

  • flutter clean中执行flutter create .

请注意,如果使用firebase,则需要重新插入GoogleService-Info.plist文件

我希望这个答案有帮助。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71137258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档