-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[RFC] CocoaPods Ranged Swift Version support #7134
Comments
@dantoml I'd argue we deprecate or remove Thoughts? |
@dnkoutso Our issue then, is what do we do when:
|
Hm good points, should we handle these cases when Pod::Spec.new do |s|
s.name = 'BanannaLib'
s.version = '1.0.0'
s.swift_version = '>= 3.2'
s.source_files = '**/*.swift'
end and:
|
Btw the RFC LGTM overall! |
@dnkoutso I think we’d actually get that for free when it tried to integrate the test project, but yes that is the behaviour that seems most obvious to me |
Minor edge case to handle, and not in the core, is a podspec providing a |
That should fail linting unless you have a very good reason IMO |
Agreed. |
IMO we should keep the |
Just wanted to chime in regarding the test native targets. I believe test native targets generated by test specs of a podspec should inherit the swift version specified. Is that correct or am I missing something @dantoml ? |
I would prefer simply:
... dropping the unnecessary (and inaccurate) (Inaccurate because we have a set of ranges of versions, not a version; and because we have a path to directories, files, and symlinks, not just files.) Other than that I really like this direction. As for @dnkoutso's comment, the answer should be yes they should inherit their parent .podspec's |
@gistya it’s not possible to lint a pod without a concrete version to build and test against, so we need to keep that file around. Subspecs will not be allowed to override or modify the swift version, and should obey the same range as the root spec. |
@dantoml is this case correct that's in the initial proposal?
Should we allow this case since Target A supports Swift 5.0 but Pod C has Swift 4.0? |
I guess depends if we treat the targets Swift version as |
@dnkoutso After your PR, |
@jshier thanks for reporting this. Do you publish podspecs in ruby and not JSON? We used to do the same but I think its preferred to publish them in JSON using Having said that, since this is a minor update (1.4.0) of CocoaPods I think we should guard against this. Will probably have a PR this week after I chat a bit with colleagues on handling this. |
Updated title to specify this is support for "Ranged" Swift version Support in 1.5.0 (if we make it). For 1.4.0 |
@dnkoutso isn't that still ignored? |
To what are you referring to? |
Any updates on this? With things like Swift support for conditional conformances or new protocols in 4.2 (
The overhead 1 would force has the potential to be non trivial, but 2 doesn't seem right either; especially since 2 would likely mean we'd be back to having to do multiple branches if there was a bug fix we needed to provide for folks that couldn't move to a new toolchain (if they are about to do an release release and cannot change the toolchain right then). fyi - SwiftPM does support indicating multiple versions, so it doesn't run into this. |
Not much progress although I do have my eyes set on this for 1.7.0 version of CocoaPods. Right now I am trying to wrap up the first 1.6.0 beta. Totally agree we should expand this to support multiple versions, perhaps an array of versions in the DSL similar to that of SwiftPM? I wouldn't mind if its the exact same functionality as SwiftPM in terms of rules of choosing Swift version to use during These are the current 1.6.0 PRs open (https://github.com/CocoaPods/CocoaPods/pulls?q=is%3Aopen+is%3Apr+milestone%3A1.6.0) but only one of the two needs to land (the test spec one) in order for 1.6.0 beta to begin as its the last feature enhancement. If anyone would like to take sometime in the meantime to expand this I'd be more than happy to review and maybe even land it in 1.6.0! I'd start here https://github.com/CocoaPods/Core/blob/master/lib/cocoapods-core/specification/dsl.rb#L132-L143 by expanding the DSL to accept an array of strings perhaps which is all supported Swift versions. |
We might also need to introduce a DSL for the Podfile to allow consumers to select a Swift version for a pod (as long as it's included in the list of supported Swift versions the pod author has declared). Like: Although today there are ways to do this via a |
Gonna mark this for 1.7.0 |
often have a use case for this! |
Core PR: CocoaPods/Core#417
CocoaPods PR: #7253
Background
These issues provide some more context, but I am happy to do a more detailed write up of my goals as a maintainer, if needs be:
Suggested Solution
DSL
Add a
swift_version
property to a specification, which allows a user to providea
Requirement
a la>= 3.2, <= 4.5
or4.0
.For example:
Linting
When linting a pod, via
pod lib lint
orpod spec lint
, we will maintainthe current behaviour of allowing a
--swift-version
or.swift-version
file.A future change for this would be to allow specifying a collection of swift
versions, such as
--swift-version=3.2,4.0,4.1
and building and testing the libfor each of these versions.
Integration
When integrating a Pod, we should always aim to use the most recent version of
Swift that is possible. Because CocoaPods does not have a way to know about
the version of Xcode that is in use, our interpretation of the 'newest' version
should be that of the target you are integrating into.
For example:
When we have multiple targets:
When Compatibility is Broken
The
swift_version
property represents the library authors intention of thecode to support the version range that they specified, with the information that
they have about past and future versions of Swift.
Due to this being unverifiable on future Swift versions at the time of publishing,
a loose version range, such as
>= 3.2
may break in the future.Authors should be mindful of this, and specify defensive ranges, rather than
being overly broad.
For example,
>= 3.2, < 5
may be a reasonable range for a pod authored today.In the cases where a resolved version of Swift proves to be incompatible, CocoaPods
will not offer a specific language to override this, as doing so for issues in transitive dependencies would require complicating much of the DSL. However, teams may override the setting with a post install hook like below:
The text was updated successfully, but these errors were encountered: