Per the Semantic Versioning Specification, prerelease versions 1.0.0-beta.3rd.1 and 1.0.0-beta.ios17.1 are different, the first expected to be less than the second one according to spec 11.4.3. However, CocoaPods currently treats these two versions as equal, leading to the installation of 1.0.0-beta.ios17.1 over 1.0.0-beta.3rd.1 when pod foo, ‘1.0.0-beta.3rd.1’ is used in the Podfile.
The issue lies in the compare_segments method of Pod::Version. The method fails to handle a case where the prerelease segments contain both String and Numeric elements, leading to an incorrect equality comparison when the types of elements at the same index differ.
I've addressed this by adding a check in the lhs <=> rhs comparison to handle cases where it returns nil, determining the types of the two elements and returning the correct result per spec 11.4.3:
Per the Semantic Versioning Specification, prerelease versions
1.0.0-beta.3rd.1
and1.0.0-beta.ios17.1
are different, the first expected to be less than the second one according to spec 11.4.3. However, CocoaPods currently treats these two versions as equal, leading to the installation of1.0.0-beta.ios17.1
over1.0.0-beta.3rd.1
whenpod foo, ‘1.0.0-beta.3rd.1’
is used in the Podfile.The issue lies in the
compare_segments
method ofPod::Version
. The method fails to handle a case where the prerelease segments contain bothString
andNumeric
elements, leading to an incorrect equality comparison when the types of elements at the same index differ.Here's an example illustrating this issue:
I've addressed this by adding a check in the
lhs <=> rhs
comparison to handle cases where it returnsnil
, determining the types of the two elements and returning the correct result per spec 11.4.3:lib/cocoapods-core/version.rb
Fix on #754