Skip to content

Commit

Permalink
Merge pull request #150 from giginet/drop-5-support
Browse files Browse the repository at this point in the history
Drop Swift 5 support
  • Loading branch information
giginet authored Oct 22, 2024
2 parents d972909 + 576da58 commit 3d8f3bc
Show file tree
Hide file tree
Showing 22 changed files with 7 additions and 464 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
env:
DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer"
jobs:
DocC:
runs-on: macos-14
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
SwiftLint:
strategy:
matrix:
xcode_version: ["15.4"]
xcode_version: ["16.0"]
env:
DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer"
runs-on: macos-14
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:

name: Upload Artifact Bundle to Release
env:
DEVELOPER_DIR: "/Applications/Xcode_15.4.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.0.app/Contents/Developer"
SCIPIO_DEVELOPMENT: 1

jobs:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
strategy:
matrix:
xcode_version:
- "15.2" # 5.9
- "15.4" # 5.10
- "16.0" # 6.0
env:
DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer"
Expand Down
89 changes: 0 additions & 89 deletions Package@swift-5.10.swift

This file was deleted.

77 changes: 0 additions & 77 deletions Package@swift-5.9.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Plugins/GenerateScipioVersion/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ struct GenerateScipioVersion: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
let zshPath = URL(filePath: "/bin/zsh") // execute dummy command

#if compiler(>=6.0)
let generatedSourceDir = context.pluginWorkDirectoryURL
#else
let generatedSourceDir = URL(filePath: context.pluginWorkDirectory.string)
#endif

let generatedSourcePath = generatedSourceDir
.appending(component: "ScipioVersion.generated.swift")
Expand Down Expand Up @@ -43,11 +39,7 @@ struct GenerateScipioVersion: BuildToolPlugin {
let standardOutput = Pipe()
let process = Process()

#if compiler(>=6.0)
let repositoryPath = context.package.directoryURL.path()
#else
let repositoryPath = context.package.directory.string
#endif

process.executableURL = URL(fileURLWithPath: "/usr/bin/git")
process.arguments = [
Expand All @@ -67,26 +59,3 @@ struct GenerateScipioVersion: BuildToolPlugin {
return revision
}
}

#if compiler(<6.0)

// Backward compatibility below 6.0 compiler
// Convert Foundation.URL to Path
extension Command {
fileprivate static func prebuildCommand(
displayName: String?,
executable: URL,
arguments: [any CustomStringConvertible],
environment: [String : any CustomStringConvertible] = [:],
outputFilesDirectory: URL
) -> PackagePlugin.Command {
.prebuildCommand(
displayName: displayName,
executable: Path(executable.path()),
arguments: arguments,
outputFilesDirectory: Path(outputFilesDirectory.path())
)
}
}

#endif
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/giginet/Scipio/tests.yml?style=flat-square&logo=github)
![Swift 6.0](https://img.shields.io/badge/Swift-6.0-FA7343?logo=swift&style=flat-square)
![Swift 5.10](https://img.shields.io/badge/Swift-5.10-FA7343?logo=swift&style=flat-square)
![Swift 5.9](https://img.shields.io/badge/Swift-5.9-FA7343?logo=swift&style=flat-square)
[![Xcode 16.0 Beta](https://img.shields.io/badge/Xcode-16.0-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/)
[![Xcode 15.4](https://img.shields.io/badge/Xcode-15.4-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/)
[![Xcode 15.2](https://img.shields.io/badge/Xcode-15.2-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/)
[![Xcode 16.0](https://img.shields.io/badge/Xcode-16.0-147EFB?style=flat-square&logo=xcode&link=https%3A%2F%2Fdeveloper.apple.com%2Fxcode%2F)](https://developer.apple.com/xcode/)
[![SwiftPM](https://img.shields.io/badge/SwiftPM-compatible-green?logo=swift&style=flat-square)](https://swift.org/package-manager/)
[![Documentation](https://img.shields.io/badge/Documentation-available-green?style=flat-square)](https://giginet.github.io/Scipio/documentation/scipio/)
![Platforms](https://img.shields.io/badge/Platform-iOS%7CmacOS%7CwatchOS%7CtvOS%7CvisionOS-lightgray?logo=apple&style=flat-square)
Expand Down Expand Up @@ -45,7 +41,7 @@ This mode is called `prepare` mode. See [Prepare All Dependencies for Your Appli
#### Define `Package.swift` to describe your application's dependencies

```swift
// swift-tools-version: 5.6
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -136,12 +132,11 @@ See [Convert Single Swift Package to XCFramework](https://giginet.github.io/Scip

## Supported Xcode and Swift version

Currently, we support Swift 5.9, and 5.10.
Currently, we support Swift 6.0.

| | Xcode | Swift |
|----|------------|-------|
|| 15.3 | 5.10 |
|| 15.0<=15.2 | 5.9 |
|| 16.0 | 6.0 |

## Reliability

Expand Down
28 changes: 0 additions & 28 deletions Sources/ScipioKit/DescriptionPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ struct DescriptionPackage {
self.packageDirectory = packageDirectory
self.mode = mode

#if swift(>=5.10)
let toolchain = try UserToolchain(swiftSDK: try .hostSwiftSDK())
#else
let toolchain = try UserToolchain(destination: try .hostDestination())
#endif
self.toolchain = toolchain

let workspace = try Self.makeWorkspace(toolchain: toolchain, packagePath: packageDirectory)
Expand Down Expand Up @@ -215,17 +211,10 @@ private final class BuildProductsResolver {
products = try topologicalSort(products) { (product) in
return product.target.dependencies.flatMap { (dependency) -> [BuildProduct] in
switch dependency {
#if compiler(>=6.0)
case .module(let module, conditions: _):
return [resolvedTargetToBuildProduct(module)]
case .product(let product, conditions: _):
return product.modules.map(resolvedTargetToBuildProduct)
#else
case .target(let target, conditions: _):
return [resolvedTargetToBuildProduct(target)]
case .product(let product, conditions: _):
return product.targets.map(resolvedTargetToBuildProduct)
#endif
}
}
}
Expand All @@ -247,19 +236,11 @@ private final class BuildProductsResolver {
let rootPackage = try fetchRootPackage()
let productNamesToBuild = rootPackage.manifest.products.map { $0.name }
let productsToBuild = rootPackage.products.filter { productNamesToBuild.contains($0.name) }
#if compiler(>=6.0)
return productsToBuild.flatMap(\.modules)
#else
return productsToBuild.flatMap(\.targets)
#endif
case .prepareDependencies:
// In prepare mode, all targets should be built
// In future update, users will be enable to specify targets want to build
#if compiler(>=6.0)
return Array(try fetchRootPackage().modules)
#else
return try fetchRootPackage().targets
#endif
}
}

Expand All @@ -271,13 +252,8 @@ private final class BuildProductsResolver {
}

private func resolveBuildProduct(from rootTarget: ScipioResolvedModule) throws -> Set<BuildProduct> {
#if compiler(>=6.0)
let dependencyProducts = Set(try rootTarget.recursiveModuleDependencies()
.flatMap(buildProducts(from:)))
#else
let dependencyProducts = Set(try rootTarget.recursiveTargetDependencies()
.flatMap(buildProducts(from:)))
#endif

switch descriptionPackage.mode {
case .createPackage:
Expand All @@ -301,11 +277,7 @@ private final class BuildProductsResolver {
return buildProducts
}

#if compiler(>=6.0)
let dependencyProducts = try target.recursiveDependencies().compactMap(\.module).flatMap(buildProducts(from:))
#else
let dependencyProducts = try target.recursiveDependencies().compactMap(\.target).flatMap(buildProducts(from:))
#endif

let buildProducts = Set([rootTargetProduct] + dependencyProducts)
buildProductsCache.updateValue(buildProducts, forKey: rootTargetProduct)
Expand Down
Loading

0 comments on commit 3d8f3bc

Please sign in to comment.