In the last 3 years. Ive probably spent 2 weeks on this issue, it comes up often if you are cloning and working on other peoples projects but doesn’t usually occur on your own.
There are a tonne of answers on the stackoverflow and sometimes you use one answer and it works and other times you have to use another answer. I have solved this issue countless times and never has the same solution worked every time.
this is the error:
‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99.
Where is this error actually coming from, what setting in flutter needs to be changed. I will list all the ways below that have been able to fix it after the error but what I want to know is where is the setting that is causing this problem in the first place.
These are the setting and ways I have used to fix this:
Updating pod file platform:
# Uncomment this line to define a global platform for your project
platform :ios, ‘13.0’
Updating AppFrameworkInfo.plist:
Updating runner deployment target in Xcode:
Updating pods deployment target in Xcode:
Changing the script in the podfile (this works but then causes other errors):
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
to this
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if config.build_settings[‘IPHONEOS_DEPLOYMENT_TARGET’].to_f < 13.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
endend
Updating the project format in Xcode:Also:Deleting pod file
Deleting podfile.lock
Deleting the pods directory
Deleting the .symlinks directory
Flutter clean
Deintegrating pods
Pod cache clean -all
Pod repo update
Pod update
Pod installI wonder if this error even represents the real issue or whether is is something else entirely because if you look at the generated podspec file it lists the ios.deployment target as 9 not 8?. Where is the error coming from and where in Flutter can this be changed?
Thanks
Okay, I understand the frustration. This `IPHONEOS_DEPLOYMENT_TARGET` issue is a recurring nightmare when working with Flutter and iOS, especially across different projects. Let\’s break down where this setting originates and how Flutter projects influence it.\n\n**Root Cause and Origin of the Error**\n\nThe error `\’IPHONEOS_DEPLOYMENT_TARGET\’ is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.4.99` fundamentally means that *some part of your iOS build process* is trying to compile code targeting iOS 8, but either your Xcode version doesn\’t support that old target or the target is lower than what the project, or one of it\’s dependencies, is built for.\n\nThe error isn\’t *necessarily* a single, easily configurable Flutter setting. It\’s often a *configuration mismatch* across multiple files and settings within your Xcode project and its dependencies (Pods). While Flutter initializes the project, the final deployment target can be influenced by several factors, making it difficult to pinpoint the *exact* source.\n\nHere\’s a breakdown of where the `IPHONEOS_DEPLOYMENT_TARGET` is specified and how these settings interact:\n\n1. **Flutter\’s Influence (Indirect):**\n\n * Flutter itself *doesn\’t directly* set `IPHONEOS_DEPLOYMENT_TARGET` in a single, easily editable file. However, Flutter has a minimum iOS deployment target. The `flutter create` command sets up the initial project structure, including the iOS project. The minimum iOS version supported by Flutter evolves.\n\n2. **`Podfile` and Ruby Scripts:**\n\n * This is a *major* source of the problem. The `Podfile` specifies the *global* platform version for your project: `platform :ios, \’13.0\’` (or whatever version you\’re using). This *should* be the primary declaration of your deployment target.\n * The `post_install` hook in the `Podfile` (the script you\’ve been modifying) is where things get complicated. The `flutter_additional_ios_build_settings(target)` method, provided by Flutter\’s CocoaPods integration, *can* override or influence the deployment target of individual Pods. This is intended to ensure compatibility between Flutter\’s requirements and the Pods. However, it doesn\’t always work perfectly, especially if Pods have conflicting deployment target requirements.\n\n3. **Xcode Project Settings (Runner.xcodeproj):**\n\n * Within Xcode, the \”Runner\” project (your main app target) has a \”Deployment Target\” setting under \”General\” tab. This setting *should* ideally match the `platform :ios, \’13.0\’` setting in your `Podfile`.\n * Individual Pods (targets within the `Pods.xcodeproj` project) *also* have their own \”Deployment Target\” settings. These are often inherited or influenced by the `Podfile` and the `post_install` script, but can sometimes be overridden or misconfigured.\n\n4. **`AppFrameworkInfo.plist`:**\n\n * While this file *can* contain `MinimumOSVersion`, it\’s usually *less* influential than the `Podfile` and Xcode project settings in determining the *actual* deployment target used during the build process. Modifying this *might* resolve the error sometimes, but it\’s generally not the root cause.\n\n5. **Generated Podspec Files**:\n * The podspec file is generated, it is not something that you can change.\n\n**Why the Inconsistent Solutions?**\n\nThe reason you\’re seeing different solutions work at different times is likely due to a combination of factors:\n\n* **Dependency Conflicts:** Different Pods might have different minimum iOS deployment target requirements.\n* **Caching/Stale Builds:** Xcode and CocoaPods can sometimes hold onto old build settings or cached data, leading to inconsistencies.\n* **Order of Operations:** The order in which CocoaPods processes the `Podfile`, the `post_install` script, and the Xcode project settings can influence the final deployment target.\n* **Flutter Version:** Flutter\’s minimum supported iOS version changes over time.\n\n**A More Systematic Approach (and Where to Look for the REAL Culprit)**\n\nInstead of randomly trying solutions, try this systematic approach:\n\n1. **Ensure Flutter is Up-to-Date:** Run `flutter doctor` and `flutter upgrade`. Use the latest stable Flutter version. This ensures you\’re using the most recent CocoaPods integration and default settings.\n\n2. **Set the Correct `platform` in `Podfile`:** Make sure your `Podfile` has the correct `platform :ios, \’XX.X\’` (e.g., `platform :ios, \’13.0\’` or higher). Choose a version that meets the *highest* minimum requirement of *any* of your dependencies.\n\n3. **Clean the Project:** Run *all* of these:\n\n “`bash\n flutter clean\n rm -rf ios/Podfile.lock\n rm -rf ios/Pods\n rm -rf ios/.symlinks\n pod cache clean –all\n flutter pub get\n cd ios\n pod deintegrate\n pod install\n cd ..\n “`\n\n4. **Xcode Verification (Critical):**\n\n * Open `ios/Runner.xcworkspace` in Xcode.\n * Select the \”Runner\” project in the Project Navigator.\n * Go to the \”General\” tab.\n * **Verify that the \”Deployment Target\” setting matches the `platform` version in your `Podfile`**. If it doesn\’t, *manually set it* to the correct version.\n * Go to the \”Build Settings\” tab. Search for `IPHONEOS_DEPLOYMENT_TARGET`. Make sure it is consistent with the above.\n * Navigate to the \”Pods\” project in the Project Navigator.\n * Check the Deployment Target settings for each individual Pod (target) to see if any are set to an older version. If so, try to update them to match your project\’s deployment target (but be careful, as this could break compatibility with the Pod). If this is the case you will need to update the post install script.\n\n5. **Examine the `Podfile.lock`:**\n\n * Open the `ios/Podfile.lock` file. Search for `IPHONEOS_DEPLOYMENT_TARGET`. This file shows the *resolved* deployment targets for all your dependencies. Look for any Pods that are still using a lower deployment target. This is a *key* indicator of a problematic dependency. If you find one, you might need to:\n * Update the Pod to a newer version.\n * Replace the Pod with an alternative.\n * If absolutely necessary, use the `post_install` script in your `Podfile` to *force* the deployment target of that specific Pod to your desired version (but be aware that this could cause runtime issues if the Pod isn\’t actually compatible). This is generally a last resort.\n * Make sure you are using the latest version of any dependencies, by running flutter pub upgrade\n\n6. **Investigate the Post Install Script:**\n\n * This is the most likely place that the actual setting is occurring. Run the project and use print statements to check each configuration `config.build_settings[\’IPHONEOS_DEPLOYMENT_TARGET\’]` to determine where the 8.0 target is being set. You may need to make it recursive to check each build configuration.\n\n7. **Xcode Project Format:** Changing the project format *can* sometimes help, especially if you\’ve upgraded Xcode versions. Try \”File\” -> \”Save As…\” and choose a newer Xcode project format.\n\n**Why the Podspec isn\’t the Whole Story**\n\nYou mentioned that the generated `podspec` file lists the `ios.deployment_target` as 9. That\’s good, but it doesn\’t guarantee that the *final* build configuration will use 9. The `Podfile` and the `post_install` script can override settings in the `podspec`, and Xcode\’s build system also plays a role.\n\n**In summary, treat this as a detective task:** systematically eliminate possible causes and carefully examine the build settings in Xcode and the `Podfile.lock` to pinpoint the dependency or setting that\’s forcing the old deployment target. Good luck!\n