Skip to content

Commit d7ea2d2

Browse files
committed
Use spm
1 parent 4bb37b2 commit d7ea2d2

File tree

14 files changed

+43
-363
lines changed

14 files changed

+43
-363
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
.vscode
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
// https://github.com/swiftlang/swift-syntax.git
7+
let package = Package(
8+
name: "SwiftSyntaxDowngrade",
9+
platforms: [
10+
.macOS(.v14), // Adjust the version as needed
11+
],
12+
dependencies: [
13+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.1")
14+
],
15+
targets: [
16+
// Targets are the basic building blocks of a package, defining a module or a test suite.
17+
// Targets can depend on other targets in this package and products from dependencies.
18+
.executableTarget(
19+
name: "SwiftSyntaxDowngrade",
20+
dependencies: [
21+
.product(name: "SwiftSyntax", package: "swift-syntax"),
22+
.product(name: "SwiftParser", package: "swift-syntax"),
23+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax")
24+
]),
25+
]
26+
)

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
This is a tool to downgrade Swift syntax from Swift 5.9 to Swift 5.3.
44

5+
## Build
6+
7+
``` bash
8+
swift build -c release
9+
```
10+
11+
512
## Usage
613

7-
``` swift
8-
let url = URL(fileURLWithPath: "path/to/your/file.swift")
9-
let result = convert(url)
10-
try! SourceFilePrinter.writeToFile(syntax: result, path: url.path)
14+
``` bash
15+
./build/release/SwiftSyntaxDowngrade <path/to/your/swiftdir>
1116
```

SwiftSyntaxDowngrade/main.swift renamed to Sources/main.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ func collectMembers(_ url: URL) {
3030
print(classesMembers)
3131
}
3232

33-
let targetDirPath: String
34-
35-
if CommandLine.arguments.count > 1 {
36-
targetDirPath = CommandLine.arguments[1]
37-
} else {
38-
targetDirPath = FileManager.default.homeDirectoryForCurrentUser.path() + "SwiftSyntaxDowngrade/SwiftSyntaxDowngrade/TestResource"
33+
guard CommandLine.arguments.count > 1 else {
34+
print("Usage: SwiftSyntaxDowngrade <path/to/your/swiftdir>")
35+
exit(1)
3936
}
37+
let targetDirPath = CommandLine.arguments[1]
38+
4039
let fm = FileManager.default
4140
let files = (fm.enumerator(atPath: targetDirPath)?.allObjects ?? [])
4241
.compactMap { $0 as? String }

0 commit comments

Comments
 (0)