Cocoapods: Raise default macOS/iOS deployment target

Created on 25 Jun 2020  Â·  33Comments  Â·  Source: CocoaPods/CocoaPods

Report

What did you do?

Built a macOS project that includes pods which do not have the deployment target set for macOS (for example, Argon2).

What did you expect to happen?

Compile without errors and warnings.

What happened instead?

It seems that starting with Xcode 12, I get a warning when building those pods (I don't get them with Xcode 11):

The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.9 to 10.16.99.

Since 10.6 is ancient, it would be nice to raise the default deployment target for macOS to 10.9 to prevent this warning.

help wanted workaround available

Most helpful comment

This Ruby script has to be inserted at the end of your Podfile after your target/pod statements e.g.

target 'SomeTests' do
    pod 'Alamofire'
    pod 'ObjectMapper' # pod 'AlamofireObjectMapper'
    pod 'AlamofireImage'    
end

post_install do |pi|
   pi.pods_project.targets.each do |t|
       t.build_configurations.each do |bc|
           if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
             bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
           end
       end
   end
end

All 33 comments

Yeap a PR would be nice and easy for this!

Alright, will do in the next days.

The same is happening with iOS btw. Even tho Podfile has info about platform and it's version:

source 'https://cdn.cocoapods.org/'

platform :ios, '11.0'
use_frameworks!

XCode 12 shows dozens of warnings for every single pod about:
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 14.0.99.

@dnkoutso Is it the same issue, or should I create a new one?

See related Swift Package Manager issue discussion at https://forums.swift.org/t/minimum-ios-version-xcode-12-and-build-warnings/40224

So to collect what I understand to be happening here:

  1. A podspec declares the packages minimum platform version for the platforms it supports
  2. Xcode 12 dropped support for some still-widely-used older platforms by, for example, eliminating support for iOS 8
  3. We are getting warnings because of the mismatch for pods that support iOS 8 (or other no-longer-supported platforms) trying to compile on Xcode 12.

This might be a naïve suggestion but, could we make the deployment target (for the targets which cocoapods generates for each pod) be set to _either_ the minimum version specified in the podspec _or_ the minimum version specified in the Podfile, whichever is greater?

(Since the only alternative appears for the community to make many PRs to many pods to individually raise each of their minimum versions to iOS 9, which seems impractical.)

I have an initial implementation working and hope to have a PR up in a few days.

~/CocoaPods/CocoaPods (1-10-stable) $ git diff
diff --git a/lib/cocoapods/installer/analyzer.rb b/lib/cocoapods/installer/analyzer.rb
index c0cef420b..bdc1329c9 100644
--- a/lib/cocoapods/installer/analyzer.rb
+++ b/lib/cocoapods/installer/analyzer.rb
@@ -860,6 +860,9 @@ module Pod
           minimum = Version.new('8.0')
           deployment_target = [deployment_target, minimum].max
         end
+        deployment_target = [deployment_target, target_definitions.first.platform.deployment_target].max
         Platform.new(platform_name, deployment_target)
       end

Based on the discussion at #10070, this does not seem to be possible to be fixed in a non-breaking way. Instead, adding a post-install script to thePodfile is a better resolution.

For example, here is one for iOS:

post_install do |pi|
   pi.pods_project.targets.each do |t|
       t.build_configurations.each do |bc|
           bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
       end
   end
end

I would also recommend filing issues to pod authors to bump the deployment target in their podspecs.

post_install do |pi|
   t = pi.pods_project.targets.find { |t| t.name == 'MyPod' }
   t.build_configurations.each do |bc|
     bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
   end
end

I think I am going to close this. While CocoaPods does not offer a "first-class" API to override values it can do it via a post_install hook which is now the recommended way to override those values or any value for that matter and the above snippets should do the trick.

In the meantime I still recommend folks to update their podspecs and specify their deployment target to begin with or update them to bump them from 8.0.

Still open to suggestions and discussions here, I will re-open this if needed.

Developing on a long-term project I am facing many of these warnings on the different cocoa pods.

  1. Do these warnings affect the library loader? On the storyboard my own custom views are not updated with casual errors mentioning different cocoa pods, seems to be related to this Xcode deployment target warnings.
  2. Updated the script and added if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0', please let me know if this is working also for your cases.

This solution is working for my needs

post_install do |pi|
   pi.pods_project.targets.each do |t|
       t.build_configurations.each do |bc|
           if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
             bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
           end
       end
   end
end

post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |bc|
if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end

It occurs to me that nobody every tells you _where in your podfile_ to put these post_install scripts exactly.

I think we should post them fully in context with a demo pod file, yeah?

hello, where do i put this code?
in the nativescript project I put it in the platforms / ios / Podfile file - unfortunately it doesn't do anything

still
[....]
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 14.0.99. (in target 'FirebaseCoreDiagnosticsInterop' from project 'Pods')
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 14.0.99. (in target 'FirebaseAnalytics' from project 'Pods')
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 14.0.99. (in target 'Fabric' from project 'Pods')
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 14.0.99. (in target 'Firebase' from project 'Pods')

[...]

This Ruby script has to be inserted at the end of your Podfile after your target/pod statements e.g.

target 'SomeTests' do
    pod 'Alamofire'
    pod 'ObjectMapper' # pod 'AlamofireObjectMapper'
    pod 'AlamofireImage'    
end

post_install do |pi|
   pi.pods_project.targets.each do |t|
       t.build_configurations.each do |bc|
           if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
             bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
           end
       end
   end
end

But ATTENTION: the best practice is to migrate the related pod source code to the minimum iOS target 9.0, because this script does not resolve the real problem at all: after running this script your project might be become uncompilable.

Do i need to do pod update after adding that code at the end, inside my platform/ios/podfile ?

No, it runs on every pod install. pod update is used to update your pod dependencies.

then how do i proceed with that? I added that post install script to the end my pod file inside platform/ios/podfile and then when i rebuild my project, it is still giving me the same error.

Remove Derived data, remove xcworkspace, run pod update / pod install and run the project again.

Can we lock this conversation please? It's not helpful at all for 99% of people, post-install hook is part of CocoaPods docs.

Remove Derived data, remove xcworkspace, run pod update / pod install and run the project again.

Can we lock this conversation please? It's not helpful at all for 99% of people, post-install hook is part of CocoaPods docs.

Unfortunately this is only resolved for projects that consume Cocoapods, not for private or custom cocoapod libraries that are distributed.

Post install hooks don’t do anything to help you when you’re trying to update your cocoapod, and it cannot lint because the default version for the generated project is too low for Xcode 12, which causes Framework dependencies to fail linting & specs updating.

@DanBurkhardt though that can be resolved manually by anyone distributing a cocoapod by updating the deployment_target in their Podspec, I agree that it would be a good idea to up the default deployment_target from pod lib create to 9.0. Luckily we're now in the realm where I feel confident opening that PR 😅 so I'll do that in the template repo.

I agree with @Kaspik that this thread can be locked since it seems like it's not practical to fix this issue for pod consumers via cocoapods core.

Why doesn't specifying the platform in the Podfile (eg platform :ios, '11.0') override the deployment target of pods? It could error/warn if the platform is lower than one of the pods deployment targets.

The pod may be using macOS APIs deprecated or even deleted in 11.0 . Only the pod provider can reliably determine the correct minimum OS version in the podspec.

My Podfile:

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
use_frameworks!
target 'Runner' do
        project 'Runner.xcodeproj'
        pod 'Firebase/Core', '6.33.0'
        pod 'Firebase/Auth', '6.33.0'
        pod 'Firebase/Messaging', '6.33.0'
        pod 'Firebase/Performance', '6.33.0'
        pod 'Firebase/RemoteConfig', '6.33.0'
        pod 'Firebase/InAppMessaging', '6.33.0'
        pod 'FirebaseFirestore', :tag => '6.33.0', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git'
        pod 'Firebase/Crashlytics', '6.33.0'
        pod 'GoogleSignIn', '5.0.2'
        pod 'GoogleTagManager', '7.1.4'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end

after run

cordova build ios --release

see in build log:

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 14.0.99. (in target 'GoogleUtilities' from project 'Pods')
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 14.0.99. (in target 'PromisesObjC' from project 'Pods')
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 14.0.99. (in target 'FirebaseMessaging' from project 'Pods')
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 14.0.99. (in target 'FirebaseCrashlytics' from project 'Pods')
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 14.0.99. (in target 'FirebaseCore' from project 'Pods')
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 14.0.99. (in target 'FirebaseAuth' from project 'Pods')
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 14.0.99. (in target 'FirebaseABTesting' from project 'Pods')
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 14.0.99. (in target 'AppAuth' from project 'Pods')
** BUILD FAILED **
The following build commands failed:
    CompileC ./platforms/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCCTLibrary/Protogen/nanopb/cct.nanopb.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler

@tbechtum how to fix that?

@burtsevyg

  1. Is there a reason you're deleting the deployment target from your pods rather than setting it to 9.0?

  2. Have you run pod install between making that change to your Podfile and running your build command? Because your function is in a post_install hook, rerunning pod install will be necessary.

(P.S. Implementation questions are usually best answered on StackOverflow - it's more set up for questions like this than Github Issues are...)

When setting IPHONEOS_DEPLOYMENT_TARGET to 11 in post install , there is build error for material components library.

https://github.com/material-components/material-components-ios/issues/10071

Undefined symbols for architecture x86_64:
  "_MDMMotionCurveMakeBezier"

This library by google is quite popular so well I believe this is or eventually could affect a lot of users. So here in that bug report someone say you should not set in post install IPHONEOS_DEPLOYMENT_TARGET . He say it should be fixed by cocoapods (he is just some developer not google contributor looks like so doesn't matter probably) , so its little back and forth with this deployment target thing... I am dealing with this repeatedly for some year or so...

I used this:

post_install do |pi|
  pi.pods_project.targets.each do |t|
    t.build_configurations.each do |bc|
      bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
    end
  end
end

Now I am switching back to this hopefully I am free of issues for at last one year...

post_install do |pi|
  pi.pods_project.targets.each do |t|
    t.build_configurations.each do |bc|
      if bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] == '8.0'
        bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end
end

This post_install solution is only a workaround because this does not include that the source code of the pod project compiles successfully against the SDK of the desired deployment target. While we are talking about new developments I think it is fair enough to de-support the iOS 8 platform. May be you will not loose a lot of clients while there are not a lot of apps supporting still iOS 8.

Do you have statistics how many active projects are still supporting iOS 8? Thanks.

Hi everyone, I've been reading everything you posted. I'm getting the same error but the thing is when I add this:

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end

And then try to run pod install this is what I'm getting:

-bash: /usr/local/bin/pod: /Applications/MAMP/Library/bin/ruby: bad interpreter: No such file or directory

What can I do to fix this?

@nicolekapp Searching Stack Overflow says the bash error you're getting is complaining that ruby can't read the pod binary. I'm gonna guess that's because you're using the copy of ruby in the MAMP Application rather than one properly installed in the CLI (the system's built-in one or one from rbenv would be better). You should investigate and debug that on Stack Overflow, though, since that kind of system setup is out of the scope of a github issue.

Once you have ruby working, do let us know if that post_install config does what you expect? I'm far from expert in this, but I am surprised to see you're deleting the deployment target for your pods rather than setting it to the value you want?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dawnnnnn picture dawnnnnn  Â·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments

k06a picture k06a  Â·  3Comments

marzapower picture marzapower  Â·  3Comments

Curtis-Halbrook picture Curtis-Halbrook  Â·  3Comments