From 8fbddcf6f3c91edbb91493938b86cf8b3b46dd6f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 10 Oct 2024 01:04:57 +0900 Subject: [PATCH] Add an escape hatch for disabling the `resources` declaration --- Package.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Package.swift b/Package.swift index aa529c772..220c5213f 100644 --- a/Package.swift +++ b/Package.swift @@ -52,3 +52,17 @@ let package = Package( ), ] ) + +// `resources` implicitly forces the package to link `Foundation` but +// we don't actually need it at runtime since the `resources` declaration +// is just for teaching carton how to bundle .js files into the package. +// For those who really want to avoid linking `Foundation` at all, you can +// set the `JAVASCRIPTKIT_NO_FOUNDATION` environment variable to any value +// before running `swift test` or `swift build` to skip the `resources` declaration. +import Foundation + +if ProcessInfo.processInfo.environment["JAVASCRIPTKIT_NO_FOUNDATION"] != nil { + for target in package.targets { + target.resources = nil + } +}