fluttercocoapodsflutter-iosflutter-ios-build

Flutter: Error (Xcode): 'Flutter/Flutter.h' file not found when running on IOS


my project a few days ago was running fine but today when i ran it, an error occurred

First I run the project normally, then I get an error message Command PhaseScriptExecution failed with a nonzero exit code like this enter image description here

i research and follow : Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code

I check to For install build only and rebuild enter image description here

but i got new err 'Flutter/Flutter.h' file not found

I'm following this link: error: 'Flutter/Flutter.h' file not found when flutter run on iOS but no ways work for me.

my flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2022.1)
[✓] VS Code (version 1.65.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

my 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

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  pod 'Firebase/Messaging'

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

  pod 'DKImagePickerController/PhotoGallery', :git => 'https://github.com/miguelpruivo/DKImagePickerController.git'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
              '$(inherited)',

              ## dart: PermissionGroup.calendar
              # 'PERMISSION_EVENTS=1',

              ## dart: PermissionGroup.reminders
              # 'PERMISSION_REMINDERS=1',

              ## dart: PermissionGroup.contacts
               'PERMISSION_CONTACTS=1',

              ## dart: PermissionGroup.camera
               'PERMISSION_CAMERA=1',

              ## dart: PermissionGroup.microphone
              # 'PERMISSION_MICROPHONE=1',

              ## dart: PermissionGroup.speech
              # 'PERMISSION_SPEECH_RECOGNIZER=1',

              ## dart: PermissionGroup.photos
               'PERMISSION_PHOTOS=1',

              ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
              # 'PERMISSION_LOCATION=1',

              ## dart: PermissionGroup.notification
               'PERMISSION_NOTIFICATIONS=1',

              ## dart: PermissionGroup.mediaLibrary
               'PERMISSION_MEDIA_LIBRARY=1',

              ## dart: PermissionGroup.sensors
              # 'PERMISSION_SENSORS=1',

              ## dart: PermissionGroup.bluetooth
              # 'PERMISSION_BLUETOOTH=1',

              ## dart: PermissionGroup.appTrackingTransparency
              # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1'
            ]
      end
  end
end

when i run with flutter run the error is

ailed to build iOS app
Error output from Xcode build:
↳
    objc[2422]: Class AppleTypeCRetimerRestoreInfoHelper is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf458) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1047904f8).
    One of the two will be used. Which one is undefined.
    objc[2422]: Class AppleTypeCRetimerFirmwareAggregateRequestCreator is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf4a8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
    (0x104790548). One of the two will be used. Which one is undefined.
    objc[2422]: Class AppleTypeCRetimerFirmwareRequestCreator is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf4f8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
    (0x104790598). One of the two will be used. Which one is undefined.
    objc[2422]: Class ATCRTRestoreInfoFTABFile is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf548) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1047905e8). One of the
    two will be used. Which one is undefined.
    objc[2422]: Class AppleTypeCRetimerFirmwareCopier is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf598) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104790638). One
    of the two will be used. Which one is undefined.
    objc[2422]: Class ATCRTRestoreInfoFTABSubfile is implemented in both /usr/lib/libauthinstall.dylib (0x1d9fbf5e8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104790688). One of
    the two will be used. Which one is undefined.
    2022-08-08 15:50:31.871 xcodebuild[2422:318480] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in
    com.apple.dt.IDEWatchSupportCore
    2022-08-08 15:50:31.871 xcodebuild[2422:318480] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension
    Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/dr/g3m_83x133sgqld2s81hkcbm0000gn/T/flutter_tools.BrO096/flutter_ios_build_temp_dirz0bX8m/temporary_xcresult_bundle

    /Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h:1:
    #import "GeneratedPluginRegistrant.h"
            ^
    /Users/anhdinhhoangquang/cloudv/ios/Runner/GeneratedPluginRegistrant.h:10:9: error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^
    1 error generated.
    <unknown>:0: error: failed to emit precompiled header
    '/Users/anhdinhhoangquang/Library/Developer/Xcode/DerivedData/Runner-hftipncmgtfzwkejzigesjjczlmu/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2VRBUORSX1OJB-clang_1S85MWRYG1P34.pch' for bridging header
    '/Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h'
    /Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h:1:9: note: in file included from /Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h:1:
    #import "GeneratedPluginRegistrant.h"
            ^
    2 errors generated.
    error: generate-pch command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/anhdinhhoangquang/cloudv/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.4.99. (in target
    'Reachability' from project 'Pods')
    /Users/anhdinhhoangquang/cloudv/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.4.99. (in target
    'OrderedSet' from project 'Pods')
    /Users/anhdinhhoangquang/cloudv/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.4.99. (in target
    'FMDB' from project 'Pods')
    /Users/anhdinhhoangquang/cloudv/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.4.99. (in target
    'AppAuth' from project 'Pods')

    Result bundle written to path:
        /var/folders/dr/g3m_83x133sgqld2s81hkcbm0000gn/T/flutter_tools.BrO096/flutter_ios_build_temp_dirz0bX8m/temporary_xcresult_bundle


Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/anhdinhhoangquang/cloudv/ios/Runner/GeneratedPluginRegistrant.h:9:8


Error (Xcode): failed to emit precompiled header
'/Users/anhdinhhoangquang/Library/Developer/Xcode/DerivedData/Runner-hftipncmgtfzwkejzigesjjczlmu/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2VRBUORSX1OJB-clang_1S85MWRYG1P34.pch' for bridging header
'/Users/anhdinhhoangquang/cloudv/ios/Runner/Runner-Bridging-Header.h'


Could not build the application for the simulator.
Error launching application on iPhone 13 Pro Max.

i'm also built by Xcode and get err like this image enter image description here


Solution

  • You could try to do this:

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

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