Description
We updated to macOS Sequoia and are trying to get SwiftWasm working again in this environment.
After installing a Swift release toolchain (6.0.1) and a matching SwiftWasm SDK, we are able to build our Swift package, with some changes.
swift.setInstance(instance);
wasi.initialize(instance);
swift.main(); // <-- new
runCmd(
"swift",
[
"build",
"--swift-sdk", // <-- new
"6.0-SNAPSHOT-2024-08-30-a-wasm32-unknown-wasi", // <-- new
// "--skip-update", // for offline support
"-c",
BUILD_CONFIG,
"--product",
PRODUCT_NAME,
"-Xswiftc",
"-Xclang-linker",
"-Xswiftc",
"-mexec-model=reactor",
"-Xlinker",
"--export-if-defined=main",
"-Xlinker",
"--export-if-defined=__main_argc_argv", // <-- new
"-Xswiftc",
"-DJAVASCRIPTKIT_WITHOUT_WEAKREFS",
],
{
cwd: swiftPackageDir,
env: { ...process.env, TOOLCHAINS: "Swift 6.0.1" }, // <-- new
shell: true,
stdio: "inherit",
}
);
After the above changes, almost everything works as expected.
Now here is the issue: previously we had issues with JavaScriptKit using resources
in its target definition (in Package.swift) under certain circumstances – I think because we were using an API that "might" be provided by Foundation if it's imported (note that the resources
flag depends on Foundation
, see here).
This happens due to this line:
.target(
name: "JavaScriptKit",
dependencies: ["_CJavaScriptKit"],
resources: [.copy("Runtime")] // <-- here
),
Now it seems we can't escape it. I can remove the resources
line and the package will build fine, but doing so would require a fork of JavaScriptKit to get reproducible builds. Do you have any idea what could be going on here? Have you seen this issue yourself at all?
![image](https://private-user-images.githubusercontent.com/5485935/371255123-f21e115f-175e-4953-b4d7-a38407382699.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMzM4MTQsIm5iZiI6MTczOTAzMzUxNCwicGF0aCI6Ii81NDg1OTM1LzM3MTI1NTEyMy1mMjFlMTE1Zi0xNzVlLTQ5NTMtYjRkNy1hMzg0MDczODI2OTkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMTY1MTU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2MyMjA5NzljYmI2NjEzNzYzYWQ2MzI3ZjZhYjAyOGFiOWNmYzkyMmUxYWE4ZmM1YjgzYzIxZmJmYjc3NTMwMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.6oaTkjOBLZWREoIBUkYjzyZCM8qMV5vwQZ8UdKzgj2o)
To be clear: we don't want or need Foundation at all in our project. It is being automatically imported due to the resources
line in JavaScriptKit's Package.swift. I can't see how to workaround this any more in Swift 6.x: it seems like something has changed such that whenever resources
is there, Foundation is required. Any ideas?