Skip to content

Commit

Permalink
Fix versioning to meet Apple's guidelines (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeykhliustin authored Mar 18, 2024
1 parent 63acef2 commit 8b68106
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 8 deletions.
18 changes: 18 additions & 0 deletions Sources/BazelPodsCore/Extensions/String+Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,22 @@ extension String {

return .orderedSame
}

var appleCompatibleVersion: String {
// Regular expression pattern to find semantic versioning parts
let pattern = #"^(\d+\.\d+\.\d+)"#

let regex = try? NSRegularExpression(pattern: pattern, options: [])
let nsVersion = self as NSString
let matches = regex?.matches(in: self, options: [], range: NSRange(location: 0, length: nsVersion.length))

if let match = matches?.first {
// Extract the matched version part which excludes pre-release or build metadata
let compatibleVersion = nsVersion.substring(with: match.range)
return compatibleVersion
}

// Return the original string if no match is found, or pattern matching fails
return self
}
}
2 changes: 1 addition & 1 deletion Sources/BazelPodsCore/Models/Specs/PodSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public final class PodSpec: PodSpecRepresentable {
let appspecs: [AppSpec]

public convenience init(JSONPodspec json: JSONDict) throws {
let version = (json["version"] as? String) ?? "1.0"
let version = (json["version"] as? String)?.appleCompatibleVersion ?? "1.0"
try self.init(JSONPodspec: json, version: version)
}

Expand Down
3 changes: 3 additions & 0 deletions TestTools/Pods_Integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
"Yoga": {
"version": "1.14.0"
},
"ZLPhotoBrowser": {
"version": "4.4.8.2"
},
"ZoomSDK": {
"version": "5.11.3.4099.1"
},
Expand Down
2 changes: 1 addition & 1 deletion Tests/Recorded/KMPNativeCoroutinesAsync/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/KMPNativeCoroutinesCombine/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/KMPNativeCoroutinesCore/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/KMPNativeCoroutinesRxSwift/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/Protobuf-C++/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/Protobuf/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/Recorded/ZLPhotoBrowser/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8b68106

Please sign in to comment.