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

SWIFT_VERSION setting in s.pod_target_xcconfig is not being respected. #7327

Closed
1 task done
ShaneQi opened this issue Jan 13, 2018 · 7 comments
Closed
1 task done

Comments

@ShaneQi
Copy link

ShaneQi commented Jan 13, 2018

Report

What did you do?

Run pod install

What did you expect to happen?

In the dependency's target build settings, SWIFT_VERSION should respect the pod's pod_target_ xcconfig setting in podspec file.

For example, in SwifterSwift's podspec file, SWIFT_VERSION is explicitly set to 4.0 (https://github.com/SwifterSwift/SwifterSwift/blob/master/SwifterSwift.podspec#L24),
but when I use SwifterSwift in my project, after I run pod install then open the workspace, the SWIFT_VERSION setting of SwifterSwift target should be 4.0 (but it's not).

1

What happened instead?

Continue with the example with SwifterSwift, the SWIFT_VERSION setting of SwifterSwift target should be 4.0, because podspec explicitly said that SwifterSwift wants to be compiled with Swift 4.0. But the SWIFT_VERSION setting is set to 3.2. Seems the xcconfig is generated, but in such a low priority so that being overridden by some default config?

CocoaPods Environment

Stack

   CocoaPods : 1.3.1
        Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
    RubyGems : 2.6.11
        Host : Mac OS X 10.13.2 (17C205)
       Xcode : 9.2 (9C40b)
         Git : git version 2.14.3 (Apple Git-98)
Ruby lib dir : /usr/local/Cellar/ruby/2.4.1_1/lib
Repositories : axxess-mi-axxessprivaterepo - ssh://stash.axxess.net/mi/axxessprivaterepo.git @ f7e6a2e5cb7f3f0781cb31ab24211e8e8135d008
               master - https://github.com/CocoaPods/Specs.git @ 2f9ce3c53d367361ae24c6d3867aeb76a026ef4b

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'PodTarget' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for PodTarget
  pod 'SwifterSwift'

end

Project that demonstrates the issue

PodTargetDemo.zip

Please extract the project and run pod install.

@ShaneQi ShaneQi changed the title SWIFT_VERSION setting in s.pod_target_xcconfig is not respected. SWIFT_VERSION setting in s.pod_target_xcconfig is not being respected. Jan 13, 2018
@ShaneQi
Copy link
Author

ShaneQi commented Jan 13, 2018

The setting was overridden by the Pods project building setting. Looks like Cocoapods writes SWIFT_VERSION = 3.0 for every target in Pods project file.

I tried to change SWIFT_VERSION of the main project, and Cocoapods is writing the same SWIFT_VERSION setting to all pod targets. This doesn't makes sense, this makes SWIFT_VERSION setting in podspec.pod_target_xcconfig meaningless, because it's going to be overridden.

@dnkoutso
Copy link
Contributor

There is a new DSL in 1.4.0.rc.1 s.swift_version to use for this.

Please use 1.4.0.rc.1 or wait for 1.4.0 to ship which hopefully should be next week.

Going to close as already "fixed".

@ShaneQi
Copy link
Author

ShaneQi commented Jan 13, 2018

@dnkoutso Just finished read the long issue #6791 , and realized that we've already solved this. Thanks a lot!

@iwllyu
Copy link

iwllyu commented Jan 25, 2018

Hey @dnkoutso, quick question: What is the default behavior if an existing pod doesn't have s.swift_version?

ex: we have a bunch of private pods that are currently in 3.2. We're releasing new versions of those pods that specify s.swift_version = '4.0'. It looks like pods that don't have this new property are also being set to 4.0 (perhaps inheriting from the project)

is that expected?

@ShaneQi
Copy link
Author

ShaneQi commented Jan 25, 2018

@iwllyu I think so, for pods without swift_version specified, they are set with the same version as the main project.

@dnkoutso
Copy link
Contributor

@iwllyu if there is no swift_version specified then the Swift Version of your app target is used.

Code:

   # @return [String] the Swift version for the target. If the pod author has provided a swift version
    #                  then that is the one returned, otherwise the Swift version is determined by the user
    #                  targets that include this pod target.
    #
    def swift_version
      spec_swift_version || target_definitions.map(&:swift_version).compact.uniq.first
    end

@iwllyu
Copy link

iwllyu commented Jan 25, 2018

thanks for the quick answers, both of you

DmitryPR pushed a commit to DmitryPR/Macaw that referenced this issue Jan 24, 2019
Define swift_version for the Podfile which is read when the library is
integrated

If this is not supplied then Macaw in Pods settings of the integrated
project gets the project's swift version which leads to a problem
if the integrator is using different Swift version in his project

For him the only workaround is to specify the post_install hook
where he sets the config.build_settings['SWIFT_VERSION'] = '4.2'

CocoaPods/CocoaPods#7327

For library developers who rely on this library this is also the problem
because the s.pod_target_xcconfig is ignored when using the cocoapods-packager

CocoaPods/cocoapods-packager#210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants