This error raises after updating Xcode to 15 because of some cocoapods version so we just need to update it, will fix the problem.
follow below steps :
#go to ios folder
cd ios
#update cocoapods
sudo gem update cocoapods
#if above doesnt work try using brew
brew install cocoapods
#make sure cocoapods updated to 1.13.0 or newer version (if available)
pod --version
#deletes build-cache which is in the /build folder
flutter clean
#delete Podfile.lock
rm Podfile.lock
#delete Pods folder as well
rm -rf Pods/
#install packages
flutter pub get
#install pod
pod install
#update pod as well
pod update
#if still not works try to invalidate caches
AndroidStudio ->File ->invalidate caches ->checks all 3 boxes ->Invalidate and Restart