Skip to content

feat: add support for Swift 5.10 #3

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 14 additions & 14 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"repositoryURL": "https://github.com/apple/swift-asn1.git",
"state": {
"branch": null,
"revision": "805deae27a7506dcad043604c00a9dc52d465dcb",
"version": "0.7.0"
"revision": "df5d2fcd22e3f480e3ef85bf23e277a4a0ef524d",
"version": "1.2.0"
}
},
{
"package": "swift-certificates",
"repositoryURL": "https://github.com/apple/swift-certificates.git",
"state": {
"branch": null,
"revision": "35a7df2d9d71c401a47de9be2e3de629a01370c2",
"version": "0.4.1"
"revision": "83640c8097acaec17c9835a083e89678cb0f2b66",
"version": "1.3.0"
}
},
{
Expand All @@ -42,34 +42,34 @@
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "33a20e650c33f6d72d822d558333f2085effa3dc",
"version": "2.5.0"
"revision": "629f0b679d0fd0a6ae823d7f750b9ab032c00b80",
"version": "3.0.0"
}
},
{
"package": "swift-driver",
"repositoryURL": "https://github.com/apple/swift-driver.git",
"state": {
"branch": "release/5.9",
"revision": "1b2b851ae4718caffa5f18fd1861bc0ddd1791a3",
"branch": "release/5.10",
"revision": "b461fd4fc51be8e1f2a3f4a2184b664b8846b46f",
"version": null
}
},
{
"package": "llbuild",
"repositoryURL": "https://github.com/apple/swift-llbuild.git",
"state": {
"branch": "release/5.9",
"revision": "d73a305d6e5a82e4bf3bf1727da3d1376e87efab",
"branch": "release/5.10",
"revision": "fd7c2e0d9279edd023ced6b0a590f8407f5472f9",
"version": null
}
},
{
"package": "SwiftPM",
"repositoryURL": "https://github.com/apple/swift-package-manager.git",
"state": {
"branch": "release/5.9",
"revision": "732d5406df67b64d266c5689454cf52aecbb4d57",
"branch": "release/5.10",
"revision": "b5f8ad931b7a40b81f64765fa08c2751164759b4",
"version": null
}
},
Expand All @@ -86,8 +86,8 @@
"package": "swift-tools-support-core",
"repositoryURL": "https://github.com/apple/swift-tools-support-core.git",
"state": {
"branch": "release/5.9",
"revision": "5665fc7641ce1a971ad06faaa476862b222ef44b",
"branch": "release/5.10",
"revision": "90bdc2a157ebacc5d3de0c83e085d05d22ca5fa0",
"version": null
}
},
Expand Down
30 changes: 25 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -7,7 +7,23 @@ let dependencies: [Package.Dependency]
let versionedTargets: [Target]
let versionedDependencies: [Target.Dependency]

#if swift(>=5.9)
#if swift(>=5.10)
dependencies = [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.3"),
.package(url: "https://github.com/apple/swift-package-manager.git", branch: "release/5.10"),
// .package(url: "https://github.com/apple/swift-tools-support-core.git", branch: "release/5.10"),
]
versionedTargets = [
.target(
name: "Xcodeproj",
dependencies: [
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
// .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
]
)
]
versionedDependencies = ["Xcodeproj"]
#elseif swift(>=5.9)
dependencies = [
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.2.3")),
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.9")),
Expand Down Expand Up @@ -58,7 +74,11 @@ versionedDependencies = []
#endif

let platforms: [SupportedPlatform]
#if swift(>=5.6)
#if swift(>=5.10)
platforms = [
.macOS(.v12),
]
#elseif swift(>=5.6)
platforms = [
.macOS(.v11),
]
Expand All @@ -83,8 +103,8 @@ let package = Package(
targets: versionedTargets + [
.target(name: "CreateXCFramework", dependencies: versionedDependencies + [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftPM-auto", package: "SwiftPM"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
// .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
]),
.testTarget(name: "CreateXCFrameworkTests", dependencies: [ "CreateXCFramework" ]),
],
Expand Down
8 changes: 4 additions & 4 deletions Sources/CreateXCFramework/PackageInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ struct PackageInfo {
self.rootDirectory = Foundation.URL(fileURLWithPath: options.packagePath, isDirectory: true).absoluteURL
self.buildDirectory = self.rootDirectory.appendingPathComponent(options.buildPath, isDirectory: true).absoluteURL

let root = try AbsolutePath(validating: self.rootDirectory.path)
let root = try TSCBasic.AbsolutePath(validating: self.rootDirectory.path)

self.toolchain = try UserToolchain(destination: try .hostDestination())

#if swift(>=5.7)
let loader = ManifestLoader(toolchain: self.toolchain)
self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader)
self.workspace = try Workspace(forRootPackage: root.absPath, customManifestLoader: loader)
#elseif swift(>=5.6)
let resources = ToolchainConfiguration(swiftCompilerPath: self.toolchain.swiftCompilerPath)
let loader = ManifestLoader(toolchain: resources)
Expand All @@ -106,12 +106,12 @@ struct PackageInfo {
#endif

#if swift(>=5.6)
self.graph = try workspace.loadPackageGraph(rootPath: root, observabilityScope: self.observabilitySystem.topScope)
self.graph = try workspace.loadPackageGraph(rootPath: root.absPath, observabilityScope: self.observabilitySystem.topScope)
let workspace = self.workspace
let scope = observabilitySystem.topScope
self.manifest = try tsc_await {
workspace.loadRootManifest(
at: root,
at: root.absPath,
observabilityScope: scope,
completion: $0
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/CreateXCFramework/ProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct ProjectGenerator {
xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { try AbsolutePath(validating: $0) },
useLegacySchemeGenerator: true
),
fileSystem: localFileSystem,
fileSystem: reallyLocalFileSystem,
observabilityScope: self.package.observabilitySystem.topScope
)
#else
Expand Down
4 changes: 2 additions & 2 deletions Sources/CreateXCFramework/Zipper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ struct Zipper {
}

#if swift(>=5.7)
private func checksum(forBinaryArtifactAt path: AbsolutePath) throws -> String {
let fileSystem = localFileSystem
private func checksum(forBinaryArtifactAt path: TSCBasic.AbsolutePath) throws -> String {
let fileSystem = TSCBasic.localFileSystem
let checksumAlgorithm = SHA256()
let archiver = ZipArchiver(fileSystem: fileSystem)

Expand Down
14 changes: 14 additions & 0 deletions Sources/Xcodeproj/Converters.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation
import TSCBasic
import Basics

Check warning on line 3 in Sources/Xcodeproj/Converters.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Sorted Imports Violation: Imports should be sorted. (sorted_imports)

//public typealias AbsolutePath = TSCBasic.AbsolutePath
public var reallyLocalFileSystem = TSCBasic.localFileSystem

extension TSCBasic.AbsolutePath {

Check warning on line 8 in Sources/Xcodeproj/Converters.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Extension Access Modifier Violation: Prefer to use extension access modifiers (extension_access_modifier)
public var absPath: Basics.AbsolutePath { try! Basics.AbsolutePath(validating: self.pathString) }

Check failure on line 9 in Sources/Xcodeproj/Converters.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Force Try Violation: Force tries should be avoided. (force_try)
}

extension Basics.AbsolutePath {

Check warning on line 12 in Sources/Xcodeproj/Converters.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Extension Access Modifier Violation: Prefer to use extension access modifiers (extension_access_modifier)
public var absPath: TSCBasic.AbsolutePath { try! TSCBasic.AbsolutePath(validating: self.pathString) }

Check failure on line 13 in Sources/Xcodeproj/Converters.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Force Try Violation: Force tries should be avoided. (force_try)
}
10 changes: 5 additions & 5 deletions Sources/Xcodeproj/SchemesGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@

private let graph: PackageGraph
private let container: String
private let schemesDir: AbsolutePath
private let schemesDir: AbsolutePath
private let isCodeCoverageEnabled: Bool
private let fs: FileSystem

Check warning on line 49 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'fs' (identifier_name)

public init(
graph: PackageGraph,
container: String,
schemesDir: AbsolutePath,
isCodeCoverageEnabled: Bool,
fs: FileSystem

Check warning on line 56 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'fs' (identifier_name)
) {
self.graph = graph
self.container = container
Expand All @@ -73,11 +73,11 @@
for target in rootPackage.targets where target.type == .executable {
let testTargets = testTargetsMap[target]

schemes.append(Scheme(

Check warning on line 76 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line. (multiline_arguments_brackets)
name: target.name,
regularTargets: [target],
testTargets: testTargets ?? []
))

Check warning on line 80 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line. (multiline_arguments_brackets)
}

// Finally, create one master scheme for the entire package.
Expand All @@ -89,7 +89,7 @@
return true
}
})
schemes.append(Scheme(

Check warning on line 92 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Multiline Arguments Brackets Violation: Multiline arguments should have their surrounding brackets in a new line. (multiline_arguments_brackets)
name: rootPackage.manifest.displayName + "-Package", // TODO: use identity instead?
regularTargets: regularTargets,
testTargets: rootPackage.targets.filter({ $0.type == .test })
Expand All @@ -107,7 +107,7 @@
try disableSchemeAutoCreation()
}

private func create(_ scheme: Scheme) throws {

Check warning on line 110 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Function Body Length Violation: Function body should span 40 lines or less excluding comments and whitespace: currently spans 87 lines (function_body_length)
assert(!scheme.regularTargets.isEmpty, "Scheme \(scheme.name) contains no target")

let stream = BufferedOutputByteStream()
Expand Down Expand Up @@ -208,12 +208,12 @@

"""

let file = try AbsolutePath(validating: scheme.filename, relativeTo: schemesDir)
let file = try AbsolutePath(validating: scheme.filename, relativeTo: schemesDir)
try fs.writeFileContents(file, bytes: stream.bytes)
}

private func disableSchemeAutoCreation() throws {
let workspacePath = try AbsolutePath(validating: "../../project.xcworkspace", relativeTo: schemesDir)
let workspacePath = try AbsolutePath(validating: "../../project.xcworkspace", relativeTo: schemesDir)

// Write the settings file to disable automatic scheme creation.
var stream = BufferedOutputByteStream()
Expand All @@ -227,12 +227,12 @@
</dict>
</plist>
"""
let settingsPlist = try AbsolutePath(validating: "xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath)
let settingsPlist = try AbsolutePath(validating: "xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath)
try fs.createDirectory(settingsPlist.parentDirectory, recursive: true)
try fs.writeFileContents(settingsPlist, bytes: stream.bytes)

// Write workspace contents file.
let contentsFile = try AbsolutePath(validating: "contents.xcworkspacedata", relativeTo: workspacePath)
let contentsFile = try AbsolutePath(validating: "contents.xcworkspacedata", relativeTo: workspacePath)
stream = BufferedOutputByteStream()
stream <<< """
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -248,7 +248,7 @@
}
}

func legacySchemeGenerator(container: String, graph: PackageGraph, codeCoverageEnabled: Bool, printer print: (String) -> Void) {

Check warning on line 251 in Sources/Xcodeproj/SchemesGenerator.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Function Body Length Violation: Function body should span 40 lines or less excluding comments and whitespace: currently spans 47 lines (function_body_length)
print("""
<?xml version="1.0" encoding="UTF-8"?>
<Scheme LastUpgradeVersion = "9999" version = "1.3">
Expand Down
Loading