Skip to content

Commit e907e5c

Browse files
Add more hints for common build failures
1 parent 1a33c51 commit e907e5c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Plugins/PackageToJS/Sources/PackageToJSPlugin.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct PackageToJSPlugin: CommandPlugin {
1919
// In case user misses the `--swift-sdk` option
2020
{ build, arguments in
2121
guard
22-
build.logText.contains(
23-
"ld.gold: --export-if-defined=__main_argc_argv: unknown option")
22+
build.logText.contains("ld.gold: --export-if-defined=__main_argc_argv: unknown option") ||
23+
build.logText.contains("-static-stdlib is no longer supported for Apple platforms")
2424
else { return nil }
2525
let didYouMean =
2626
[
@@ -53,13 +53,26 @@ struct PackageToJSPlugin: CommandPlugin {
5353
3. Select a matching SDK version with --swift-sdk option
5454
"""
5555
}),
56+
(
57+
// In case selected toolchain is a Xcode toolchain, not OSS toolchain
58+
{ build, arguments in
59+
guard build.logText.contains("No available targets are compatible with triple \"wasm32-unknown-wasi\"") else {
60+
return nil
61+
}
62+
return """
63+
The selected toolchain might be an Xcode toolchain, which doesn't support WebAssembly target.
64+
65+
Please use a swift.org Open Source toolchain with WebAssembly support.
66+
See https://book.swiftwasm.org/getting-started/setup.html for more information.
67+
"""
68+
}),
5669
]
5770
private func reportBuildFailure(
5871
_ build: PackageManager.BuildResult, _ arguments: [String]
5972
) {
6073
for diagnostic in Self.friendlyBuildDiagnostics {
6174
if let message = diagnostic(build, arguments) {
62-
printStderr("\n" + message)
75+
printStderr("\n" + "Hint: " + message)
6376
}
6477
}
6578
}

0 commit comments

Comments
 (0)