Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pods are always installed for iOS 8 deployment target instead of iOS 9 #7314

Closed
Coeur opened this issue Jan 8, 2018 · 54 comments
Closed

pods are always installed for iOS 8 deployment target instead of iOS 9 #7314

Coeur opened this issue Jan 8, 2018 · 54 comments
Labels
s1:awaiting input Waiting for input from the original author
Milestone

Comments

@Coeur
Copy link
Contributor

Coeur commented Jan 8, 2018

Report

What did you do?

  1. Create a new Xcode 9.2 project "example" for iOS Swift
  2. Change deployment target to iOS 9.0
  3. Use a Podfile with:
platform :ios, '9.0'
use_frameworks!

abstract_target 'default_pods' do
    pod 'AFNetworking', '~> 3'
    target 'example'
end
  1. Run pod install or pod update

What did you expect to happen?

AFNetworking is installed with a Deployment Target of iOS 9.0.

What happened instead?

AFNetworking is installed with a Deployment Target of iOS 8.0, which causes noticeable warnings like /Users/coeur/example/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m:163:30: 'setResumingHandler:' is only available on iOS 9.0 or newer

Even if I manually change the Pods project Deployment Target to iOS 9.0, a simple pod update will reset it to iOS 8.0.

CocoaPods Environment

  • CocoaPods 1.4.0.rc.1 (also reproduced with CocoaPods 1.3.1)
  • Xcode 9.2 & High Sierra

Project that demonstrates the issue

https://github.com/Coeur/CocoaPods7314

@Coeur
Copy link
Contributor Author

Coeur commented Jan 8, 2018

I found the following workaround, adding a post_install hook:

platform :ios, '9.0'
use_frameworks!

abstract_target 'default_pods' do
    pod 'AFNetworking', '~> 3'
    target 'example'
end

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

@dnkoutso
Copy link
Contributor

dnkoutso commented Jan 8, 2018

Can you please provide a sample project and use the template given to you when you file a new issue?

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Jan 8, 2018
@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Jan 9, 2018
@Coeur
Copy link
Contributor Author

Coeur commented Jan 9, 2018

@dnkoutso Done, with a screenshot.

@dnkoutso
Copy link
Contributor

dnkoutso commented Jan 9, 2018

@Coeur still dont think its a CocoaPods bug. The podspec of AFNetworking sets deployment target to 7.0 but I think because you are using Xcode 9.2 which does not contain iOS 7.0 it defaults to the next available version.

https://github.com/CocoaPods/Specs/blob/d0ec5a65e80656c8d78e12ff19f251df879e0bc2/Specs/a/7/5/AFNetworking/3.1.0/AFNetworking.podspec.json#L21

Podspecs can define their own deployment target which gets set by the CocoaPods library.

I do not see any particular issue with CocoaPods library here. Will close this one but please reply here if you feel strongly there is an issue here...

@dnkoutso dnkoutso closed this as completed Jan 9, 2018
@dnkoutso
Copy link
Contributor

dnkoutso commented Jan 9, 2018

Yes, Xcode 9 drops iOS 7.0 support so that's why you get iOS 8.0 instead despite the podspec mentioning 7.0

https://stackoverflow.com/questions/45640715/how-to-set-up-xcode-9-for-iphone-4-and-iphone-4s-development

@Coeur
Copy link
Contributor Author

Coeur commented Jan 9, 2018

@dnkoutso , you mean that in a Podspec, I can only forcibly define an exact Deployment Target, I can't simply define the minimal supported Deployment Target?

When I write a Podspec, I use platforms.ios to define what is at least required to build, not to define what must be built.

In all case, no matter the Podspec, it is an integration bug from CocoaPods to build for iOS 8+ when we want an iOS 9+ project.

@Jinxiansen
Copy link

@dnkoutso @Coeur
How to specify two different platforms in a pod,
I have two target, respectively, support for iOS 8 and iOS 9, how to distinguish?

@dnkoutso
Copy link
Contributor

I do not think this is supported currently.

@Coeur
Copy link
Contributor Author

Coeur commented Jan 12, 2018

@Jinxiansen , it doesn't even work for one single platform as described by this bug report. But if one day there is support for multi platforms, then the documentation will tell you. One suggestion could be:

abstract_target 'default_pods' do
    target 'One' do
        platform :ios, '8.0'
    end
    target 'Two' do
        platform :ios, '9.0'
    end
end

It's pure suggestion for the future: this is in no way a working piece of configuration in 2018

@Coeur
Copy link
Contributor Author

Coeur commented Apr 11, 2018

@Jinxiansen don't forget you have to do pod install (or pod deintegrate && pod install) to get the post_install to execute at least once. It will not work with only pod update.

@Whirlwind
Copy link
Contributor

I think the deployment target version should be equal to the user target version.

If the pod target's deployment version is equal to iOS 9 which define by user target, the dependency will use their new api if they check the deploy version:

#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100)
            configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
#else
            configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
#endif

The code from the AFNetworking. In the podspec, there is a platforms":{"ios":"7.0","osx":"10.9","tvos":"9.0"}. So the pod target is deploy to iOS 7.0, and the macro will always be false! AFNetworking will always use the old api.

@lolgear
Copy link

lolgear commented May 31, 2018

@dnkoutso

So, I have UICKeychainStore in Pods.xcodeproj.

Pods.xcodeproj has deployments targets:

Pods (Project) -> 9.0
UICKeychainStore -> 8.0

My App deployment target -> 9.3

I would like to keep them in sync in case of aesthetics.

@Coeur
If you can't reopen issue and it have not solved yet, it is time to make open-radar for CocoaPods.

@dnkoutso dnkoutso reopened this May 31, 2018
@ayushgoel
Copy link

+1

I was hoping the deployment target would be defined according to the platform specified.

platform :ios, '9.0'

@BB9z
Copy link

BB9z commented Sep 18, 2018

Coeur's multiple platforms script seems wrong could be improved. I write a new one.

post_install do |pi|
    # https://github.com/CocoaPods/CocoaPods/issues/7314
    fix_deployment_target(pi)
end

def fix_deployment_target(pod_installer)
    if !pod_installer
        return
    end
    puts "Make the pods deployment target version the same as our target"
    
    project = pod_installer.pods_project
    deploymentMap = {}
    project.build_configurations.each do |config|
        deploymentMap[config.name] = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
    end
    # p deploymentMap
    
    project.targets.each do |t|
        puts "  #{t.name}"
        t.build_configurations.each do |config|
            oldTarget = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
            newTarget = deploymentMap[config.name]
            if oldTarget == newTarget
                next
            end
            puts "    #{config.name} deployment target: #{oldTarget} => #{newTarget}"
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = newTarget
        end
    end
end

Add this to the Podfile, then pod install may generate output like

...
Generating Pods project
Make the pods deployment target version the same as our target
  AFNetworking
    Release deployment target: 7.0 => 9.0
    Debug deployment target: 7.0 => 9.0
    Alpha deployment target: 7.0 => 9.0
  FLEX
    Release deployment target: 8.0 => 9.0
    Debug deployment target: 8.0 => 9.0
    Alpha deployment target: 8.0 => 9.0
...

@Coeur
Copy link
Contributor Author

Coeur commented Sep 18, 2018

@BB9z, I'm unsure what you mean by "seems wrong", as I'm successfully using the 7 lines workaround from my January 8th post.

But best thing would be to have the fix at CocoaPods level, so if you're confident you should make a pull request to fix CocoaPods regarding this.

@BB9z
Copy link

BB9z commented Sep 18, 2018

@Coeur assume we had a podfile:

target 'One' do
    platform :ios, '8.0'
    pod 'A'    # A has a deployment target 6.0, we want it build with 8.0
    pod 'B'   # B has a deployment target 7.0, we want it build with 8.0
end

target 'Two' do
    platform :ios, '9.0'
    pod 'A'    # A has a deployment target 6.0, we want it build with 9.0
    pod 'B'    # B has a deployment target 7.0, we want it build with 9.0
end

In my options, your script will define the deployment targets for "One" and "Two" respectively. But actually, you change nothing. t.name is the name of the pod target, not our application.

pi.pods_project.targets.each do |t|
  # t is pod target, not our app target
  p t.name # will log A and B
end

@Coeur
Copy link
Contributor Author

Coeur commented Sep 18, 2018

@BB9z The workaround from my January 8th post (second post of this thread) is certainly not for mixing deployment targets: it's for the issue reported in the preceeding post (first post of this thread), with a single desired deployment target (iOS 9 for instance).

I don't understand why people are diverging the discussion on supporting multiple deployment target when it doesn't even work correctly for one single unique deployment target: if the target is built for 9.0, then the Pods should build for 9.0, not for 8.0. That's all there is in this issue report.

It's nice to want to support more stuff, but it should come as fixes to the actual CocoaPods gem, not as complex workarounds in people's Podfile. This is an issue ticket, not a StackOverflow post. :)

@amorde
Copy link
Member

amorde commented Sep 28, 2018

It seems that it would make sense to bump the deployment target to the user project's value if it is higher than the podspec's deployment target. @dnkoutso can you think of any issues that may arise from doing that?

@lolgear
Copy link

lolgear commented Sep 28, 2018

@amorde If person has one project/workspace for several targets ( for example, several "typical" targets ), these targets could be out of sync in "deployment target dimension", but Pods are shared between these "typical" targets.

Typical targets are either app extensions or cloned apps ( some teams have clones of their main app for rebranding reasons before "big daddy money income").

@amorde
Copy link
Member

amorde commented Sep 28, 2018

ah, I forgot that a target can specify a deployment target lower than the project one. bummer.

@stale
Copy link

stale bot commented Dec 27, 2018

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

@stale stale bot added the s1:awaiting input Waiting for input from the original author label Dec 27, 2018
@Speakus
Copy link

Speakus commented Dec 27, 2018

I believe the issue is duplicated with this one: #8069 but for my opinion current issue is better described

@LinusU
Copy link
Contributor

LinusU commented Jul 29, 2019

@icecrystal23

I don't understand what benefit would be gained from updating the minimum deployment target to something higher than what the library was written for. [...]

I've posted this in #4859, but it seems very relevant here:

Since I have a deployment target of iOS 12 in my main app, my app doesn't build arm 32-bit code, but since some of the pods have a much lower deployment target they do. This leaves me with linking errors when I'm trying to archive the app, and the only fix I've found is to bump the deployment target to 12 on all my pods as well.

I think it would be very neat if CocoaPods could always propagate my platform :ios, '12.0' down to the individual pods deployment target. That way all pods would be optimized to run for the appropriate platform!

#4859 (comment)

@icecrystal23
Copy link
Contributor

@LinusU you are then consuming the Pods in a way not intended by the authors. You can choose to apply that workaround, but it is not a good general policy that should be blindly applied to all pods.

@Coeur
Copy link
Contributor Author

Coeur commented Jul 30, 2019

@icecrystal23 you're probably wrong about that: pod authors may support MULTIPLE versions of iOS, while the podspec only let us define the minimum one.

@LinusU
Copy link
Contributor

LinusU commented Jul 30, 2019

[...] but it is not a good general policy that should be blindly applied to all pods.

I don't really see how that is sustainable, should I only use pods that specifically targets iOS 12? That seems quite strange. Surely there should be no ill effects by compiling with a newer deployment target? 🤔

@icecrystal23
Copy link
Contributor

You guys are still acting like you can't run a library built for iOS 8 on iOS 12. You can. It is a minimum deployment target. Meaning the library supports iOS 8 and newer.

I don't know what linker errors you are getting, but in general you can compile and link with older minimum targets just fine.

@Westacular
Copy link
Contributor

@LinusU A workaround for the specific issue of dropping 32-bit code when targeting iOS 11+ is to set ARCHS = "$(ARCHS_STANDARD_64_BIT)" in your app target. CocoaPods does automatically copy this setting to all Pods targets. (Xcode will give an "update to recommended settings" warning about this, but that seems like a lesser evil.)

@LinusU
Copy link
Contributor

LinusU commented Aug 2, 2019

@Westacular that's amazing, thanks!!

edit: I haven't been able to trigger this, would you mind elaborating on when it does that?

Xcode will give an "update to recommended settings" warning about this, but that seems like a lesser evil.

edit2: Ahhhh, read that the other way around, I thought that Xcode would ask me to go to ARCHS_STANDARD_64_BIT if I targeted iOS 11+ 😄

Hmm, I wonder why it doesn't use ARCHS_STANDARD_64_BIT for iOS 11+ then 🤔

@stale
Copy link

stale bot commented Dec 22, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

@stale
Copy link

stale bot commented Dec 29, 2019

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@SohaibSiddique
Copy link

I found the following workaround, adding a post_install hook:

platform :ios, '9.0'
use_frameworks!

abstract_target 'default_pods' do
    pod 'AFNetworking', '~> 3'
    target 'example'
end

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

its working for me in 2021

@MLukman
Copy link

MLukman commented Sep 3, 2021

Still happening today

@Coeur
Copy link
Contributor Author

Coeur commented Sep 4, 2021

Well, the topic was closed by a bot, not because it was resolved.
If you wish for a solution that doesn't involve the workaround (see the second post, "Coeur commented on 8 Jan 2018"), then you'd need to create a new GitHub issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s1:awaiting input Waiting for input from the original author
Projects
None yet
Development

Successfully merging a pull request may close this issue.