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
  • Loading branch information
Antonio Strijdom committed Sep 27, 2024
1 parent 351fae7 commit 5cc1bef
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 5 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
75 changes: 75 additions & 0 deletions Example/Packages/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// swift-tools-version: 6.0

// This file was automatically generated by PackageGenerator and untracked
// PLEASE DO NOT EDIT MANUALLY

import PackageDescription

let package = Package(
name: "Example",
defaultLocalization: "en",
platforms: [
.iOS(.v15),
.macOS(.v13),
],
products: [
.library(
name: "Example",
targets: ["Example"]
),
],
dependencies: [
.package(
path: "../MyFrameworks"
),
.package(
url: "https://github.com/DependencyA",
exact: "1.0.0"
),
.package(
url: "https://github.com/DependencyB",
exact: "2.0.0"
),
.package(
url: "https://github.com/DependencyC",
revision: "abcde1235kjh"
),
],
targets: [
.target(
name: "Example",
dependencies: [
.product(name: "RemoteDependencyA", package: "RemoteDependencyA"),
.target(name: "LocalXCFramework"),
],
path: "Framework/Sources",
resources: [
.process("Resources")
],
plugins: [
]
),
.testTarget(
name: "UnitTests",
dependencies: [
.byName(name: "Example"),
.product(name: "RemoteDependencyB", package: "RemoteDependencyB"),
.target(name: "LocalXCFramework"),
],
path: "Tests/Sources",
resources: [
.process("Resources")
],
plugins: [
]
),
.binaryTarget(
name: "LocalXCFramework",
path: "../LocalXCFramework.xcframework"
),
],
swiftLanguageModes: [
.version("5.10"),
.version("6.0"),
]
)
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"version" : "1.0.1"
}
},
{
"identity" : "semver.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/glwithu06/Semver.swift.git",
"state" : {
"revision" : "53073d00185c49d5bdedc13e3697f5eb760fc2ad",
"version" : "1.2.0"
}
},
{
"identity" : "shellout",
"kind" : "remoteSourceControl",
Expand Down
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ let package = Package(
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2"),
.package(url: "https://github.com/SwiftGen/StencilSwiftKit", from: "2.8.0"),
.package(url: "https://github.com/JohnSundell/ShellOut", from: "2.3.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6")
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
.package(url: "https://github.com/glwithu06/Semver.swift.git", from: "1.2.0")
],
targets: [
.executableTarget(
Expand All @@ -22,7 +23,8 @@ let package = Package(
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "ShellOut", package: "ShellOut"),
.product(name: "StencilSwiftKit", package: "StencilSwiftKit"),
.product(name: "Yams", package: "Yams")
.product(name: "Yams", package: "Yams"),
.product(name: "Semver", package: "Semver.swift")
],
path: "Sources"),
.testTarget(
Expand Down
10 changes: 10 additions & 0 deletions Sources/Core/Spec+Context.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Spec+Context.swift

import Foundation
import Semver

extension Spec.Product {
func makeContext() -> [String: Any] {
Expand Down Expand Up @@ -33,6 +34,14 @@ extension Spec.RemoteDependency {
}

extension Spec {
var swiftToolsVersionMajor: Int? {
guard let swiftToolsVersionString = swiftToolsVersion else { return nil }
if let swiftToolsVersion = try? Semver(string: swiftToolsVersionString) {
return Int(swiftToolsVersion.major)
}
return nil
}

func makeContext() -> [String: Any] {
let values: [String: Any?] = [
"package_name": name,
Expand All @@ -44,6 +53,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 5cc1bef

Please sign in to comment.