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

Replaced swiftLanguageVersions with swiftLanguageModes for Swift 6 onwards #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All we really need 👍

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