Skip to content

Commit 04d4497

Browse files
committed
Create 0.50700.0 relesae of SwiftSyntax
1 parent 9716bcb commit 04d4497

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Package.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ if let parserLibSearchPath = ProcessInfo.processInfo.environment["SWIFT_SYNTAX_P
3535
swiftSyntaxParserLinkerSettings = []
3636
}
3737

38+
// Include the parser library as a binary dependency if both the host and the target are macOS.
39+
// - We need to require that the host is macOS (checked by `#if os(macOS)`) because package resolve will download and unzip the referenced framework, which requires `unzip` to be installed. Only macOS guarantees that `unzip` is installed, the Swift Docker images don’t have unzip installed, so package resolve would fail.
40+
// - We need to require that the target is macOS (checked by `.when`) because binary dependencies are only supported by SwiftPM on macOS.
41+
#if os(macOS)
42+
let parserLibraryTarget: [Target] = [.binaryTarget(
43+
name: "_InternalSwiftSyntaxParser",
44+
url: "https://github.com/apple/swift-syntax/releases/download/0.50700.0/_InternalSwiftSyntaxParser.xcframework.zip",
45+
checksum: "7034a98bd9244417d0a2fa0b92047d07883221a21cc696004ad09395ad291afa"
46+
)]
47+
let parserLibraryDependency: [Target.Dependency] = [.target(name: "_InternalSwiftSyntaxParser", condition: .when(platforms: [.macOS]))]
48+
#else
49+
let parserLibraryTarget: [Target] = []
50+
let parserLibraryDependency: [Target.Dependency] = []
51+
#endif
52+
3853
let package = Package(
3954
name: "SwiftSyntax",
4055
products: [
@@ -87,7 +102,7 @@ let package = Package(
87102
),
88103
.target(
89104
name: "SwiftSyntaxParser",
90-
dependencies: ["SwiftSyntax"],
105+
dependencies: ["SwiftSyntax"] + parserLibraryDependency,
91106
exclude: [
92107
"NodeDeclarationHash.swift.gyb"
93108
],
@@ -115,5 +130,5 @@ let package = Package(
115130
dependencies: ["SwiftSyntax", "SwiftSyntaxParser"],
116131
exclude: ["Inputs"]
117132
),
118-
]
133+
] + parserLibraryTarget
119134
)

0 commit comments

Comments
 (0)