0

I had used a lots and lots of solutions for the past 3 days, but still i couldn't get rid of this issue, please help me out.

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.

Im using Flutter v2.8.1, i also tried with different versions like v2.5.1, v2.10.1, but no use... and also tried with various stackoverflow solutions but didn't helped me out.

POD FILE:

# 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

Thanks in Advance!

New error after done below solution

/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.
Abilash S
  • 1
  • 1
  • Does this answer your question? [error: 'Flutter/Flutter.h' file not found when flutter run on iOS](https://stackoverflow.com/questions/64973346/error-flutter-flutter-h-file-not-found-when-flutter-run-on-ios) – Ashutosh singh Feb 16 '22 at 07:44
  • hello under my answer i have post a comment that is the answer your next problem with the IPHONEOS_DEPLOYMENT_TARGET – liam spiegel Feb 17 '22 at 10:05

2 Answers2

0

Change your Podfile

from this

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

to this

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
Anandh Krishnan
  • 804
  • 7
  • 16
  • try this and ping me whether works or not – Anandh Krishnan Feb 16 '22 at 06:51
  • When i did this, it shows different error like app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'PINCache' from project 'Pods') – Abilash S Feb 16 '22 at 09:15
0

to solve the bug continue this steps:

  1. Backup the Runner directory
  2. Delete the ios directory
  3. Go to a terminal and execute flutter create . in the flutter project folder
  4. Paste your Runner folder back into the ios directory
  5. pod deintegrate in the ios directory
  6. pod install also in the ios directory
  7. flutter clean in the flutter project directory
  8. flutter pub get
  9. flutter run

Please note that if you use firebase you need to re-insert the GoogleService-Info.plist file

I hope this answer is helpful

liam spiegel
  • 264
  • 2
  • 10
  • at step 6 : [!] CocoaPods could not find compatible versions for pod "better_player": In Podfile: better_player (from `.symlinks/plugins/better_player/ios`) Specs satisfying the `better_player (from `.symlinks/plugins/better_player/ios`)` dependency were found, but they required a higher minimum deployment target. [!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`. – Abilash S Feb 17 '22 at 08:55
  • # Uncomment this line to define a global platform for your project platform :ios, '12.0' When i add like this that works(pod install) But after further steps i got error like app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'GoogleSignIn' from project 'Pods') – Abilash S Feb 17 '22 at 08:56
  • simple open ios > Pods > Pods.xcodeproj in xCode. then go to generel and set the IPHONEOS_DEPLOYMENT_TARGET to 9.0 – liam spiegel Feb 17 '22 at 09:45
  • I had done that and that issue solved and now comes with a new error which i mentioned above – Abilash S Feb 17 '22 at 12:15
  • what is the new error? – liam spiegel Feb 17 '22 at 13:16
  • I added the error message above – Abilash S Feb 18 '22 at 04:42