Finally after days of trying and error, I found a way to work it out..
So, I noticed several things that might cause an error when building for iOS.
Never run the command pod install manually.
Do not add the line pod install Firebase to your podfile. Instead, just override all of the firebase dependencies using $FirebaseSDKVersion = '8.0.0'
Don't forget to specify your iOS Deployment target on your podfile and match it with the deployment target on your Runner.xcworkspace file (Both in the runner and in the target)
So, if you already have a project, here are the steps I recommend, as this works perfectly for me:
Delete the Pods directory, the /ios/podfile.lock, and the ios/Flutter/Flutter.podspec
Run pod deintegrate
Delete all of the contents inside your DerivedData folder.. you can run rm -rf ~/Library/Developer/Xcode/DerivedData/*
Run flutter clean
Run flutter pub get
Run flutter build ios. Note thas this will also run the pod install command.
Close your editor, and open your Runner.xcworkspace on XCode and run your XCode. Clean your build folder. If there's an option to update your project settings, accept it.
You might get several warnings about deprecated functions, but in my case, my app run just fine..
I don't know about the details on why it happened, but from what I noticed, Cocoapods have a different version of some of the firebase packages for ios.. I hope someone can explain it..
--
Things to note :
If build your app on XCode, and then use flutter run either on terminal or VSCode, you would get some warnings like Class AMSupportURLConnectionDelegate is implemented in both. So, from my personal experience, I always run my app from XCode.
If you use Google Sign In, follow the steps here you don't need to add anything in your podfile.
For reference, here is my podfile content.
# Uncomment the next line to define a global platform for your project
# platform :ios, '12.0'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
$FirebaseSDKVersion = '8.0.0'
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.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
I hope it works for you! Goodluck!