After I updated flutter to the latest version I keep getting this error for GoogleMobileAds and GoogleMaps
When I try to flutter build ios
I get the same error
Lexical or Preprocessor Issue (Xcode): 'GoogleMaps/GoogleMaps.h' file not found /Users/.../.pub-cache/hosted/pub.dev/google_maps_flutter_ios-2.3.1/ios/Classes/GoogleMa pPolylineController.h:5:8
Lexical or Preprocessor Issue (Xcode): 'GoogleMobileAds/GoogleMobileAds.h' file not found /Users/.../.pub-cache/hosted/pub.dev/google_mobile_ads-4.0.0/ios/Clas ses/NativeTemplates/GoogleAdsMobileIosNativeTemplates/GADTTemplateView.h:14: 8
(Depending which package is found in the pubspec)
System
[✓] Flutter (Channel stable, 3.19.1, on macOS 13.5.1 22G90 darwin-arm64,
locale en-GR)
[✓] Android toolchain - develop for Android devices (Android SDK version
34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.86.2)
[✓] Connected device (2 available)
[✓] Network resources
In the project I first encountered this issue has a lot of packages but at first I was using google_mobile_ads: ^2.3.0
Many suggested to try on a new project but no luck there I get the same issue, I also tried one of the examples from the google ads repo and I get the same issue... I even tried from Codemagic to build my app and again I get the same issue...
I have also tried:
rm -rf Pods Podfile.lock
pod cache clean --all
along with flutter pub cache clean
I have been searching for a solution for over 2 weeks now this is becoming extremely frustrating, please help me out on this. Below is my podfile and the dependencies of my pubspec.
# Uncomment this line to define a global platform for your project
platform :ios, '14.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
pod 'MLKitVision', :podspec => 'MLKitVision.podspec.json'
pod 'MLKitCommon', :podspec => 'MLKitCommon.podspec.json'
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
# Ensure pods also use the minimum deployment target set above
# https://stackoverflow.com/a/64385584/436422
puts 'Determining pod project minimum deployment target'
pods_project = installer.pods_project
deployment_target_key = 'IPHONEOS_DEPLOYMENT_TARGET'
deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
minimum_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }
puts 'Minimal deployment target is ' + minimum_deployment_target
puts 'Setting each pod deployment target to ' + minimum_deployment_target
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
#config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings[deployment_target_key] = minimum_deployment_target
end
end
end
I left some other google packages just in case that might have to do anything with my problem because I face the same issue with google maps
environment:
sdk: '>=2.18.4 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_riverpod:
cupertino_icons: ^1.0.2
firebase_core: ^2.7.1
firebase_auth: ^4.6.3
cloud_firestore: ^4.8.2
firebase_messaging: ^14.2.6
firebase_analytics: ^10.1.5
firebase_crashlytics: ^3.0.16
connectivity_plus: ^3.0.3
intl: any
google_fonts: ^4.0.3
firebase_storage: ^11.0.16
google_sign_in: ^6.1.5
bloc: ^8.1.1
equatable: ^2.0.5
flutter_bloc: ^8.1.2
...
google_maps_flutter: ^2.5.3
geolocator: ^9.0.2
geocoding: ^2.1.0
firebase_ui_firestore: ^1.5.6
google_mobile_ads: 4.0.0
flutter_launcher_icons:
...
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
mockito: ^5.4.2
build_runner: ^2.4.6
Posting in hopes that one day this might help someone out. I ended up deleting from my MacBook the pub cache and cocoa pods completely from the device and then re installing them. Once I had done that my app worked fine again.