Skip to content

Commit

Permalink
Replaced swiftLanguageVersions with swiftLanguageModes for Swift 6 on…
Browse files Browse the repository at this point in the history
…wards (#8)


---------

Co-authored-by: Antonio Strijdom <[email protected]>
  • Loading branch information
antoniostrijdom and Antonio Strijdom authored Sep 30, 2024
1 parent 351fae7 commit f156353
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Example/Packages/Example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
".iOS(.v15)",
".macOS(.v13)"
],
"swiftToolsVersion": "5.10",
"swiftToolsVersion": "6.0",
"swiftLanguageVersions": [
"5.10",
"6.0"
Expand Down Expand Up @@ -69,4 +69,4 @@
"path": "../LocalXCFramework.xcframework"
}
]
}
}
2 changes: 1 addition & 1 deletion Example/Packages/Example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Example
platforms:
- ".iOS(.v15)"
- ".macOS(.v13)"
swiftToolsVersion: '5.10'
swiftToolsVersion: '6.0'
swiftLanguageVersions:
- '5.10'
- '6.0'
Expand Down
9 changes: 9 additions & 0 deletions Sources/Core/Spec+Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ extension Spec.RemoteDependency {
}

extension Spec {
var swiftToolsVersionMajor: Int? {
guard let swiftToolsVersionString = swiftToolsVersion else { return nil }
if let majorString = swiftToolsVersionString.components(separatedBy: ".").first {
return Int(majorString)
}
return nil
}

func makeContext() -> [String: Any] {
let values: [String: Any?] = [
"package_name": name,
Expand All @@ -44,6 +52,7 @@ extension Spec {
"local_binary_targets": localBinaryTargets,
"remote_binary_targets": remoteBinaryTargets,
"swift_tools_version": swiftToolsVersion,
"swift_tools_version_major": swiftToolsVersionMajor,
"swift_versions": swiftLanguageVersions
]
return values.compactMapValues { $0 }
Expand Down
8 changes: 8 additions & 0 deletions Templates/Package.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ let package = Package(
{% endfor %}
{% if swift_versions %}
],
{% if swift_tools_version_major %}
{% if swift_tools_version_major >= 6 %}
swiftLanguageModes: [
{% else %}
swiftLanguageVersions: [
{% endif %}
{% else %}
swiftLanguageVersions: [
{% endif %}
{% for swift_version in swift_versions %}
.version("{{ swift_version }}"),
{% endfor %}
Expand Down

0 comments on commit f156353

Please sign in to comment.