From e771c7b8da5d8434acd843ef6742900a398cf0c5 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Mon, 16 Feb 2026 17:50:38 -0500 Subject: [PATCH] Enable bridging of JSContext --- Package.swift | 13 +++++++++++++ Sources/SkipScript/JSContext.swift | 2 ++ 2 files changed, 15 insertions(+) diff --git a/Package.swift b/Package.swift index 572c9f2..7c62346 100644 --- a/Package.swift +++ b/Package.swift @@ -24,3 +24,16 @@ let package = Package( ], plugins: [.plugin(name: "skipstone", package: "skip")]), ] ) + +if Context.environment["SKIP_BRIDGE"] ?? "0" != "0" { + package.dependencies += [.package(url: "https://source.skip.tools/skip-bridge.git", "0.0.0"..<"2.0.0")] + package.targets.forEach({ target in + target.dependencies += [.product(name: "SkipBridge", package: "skip-bridge")] + }) + // all library types must be dynamic to support bridging + package.products = package.products.map({ product in + guard let libraryProduct = product as? Product.Library else { return product } + return .library(name: libraryProduct.name, type: .dynamic, targets: libraryProduct.targets) + }) +} + diff --git a/Sources/SkipScript/JSContext.swift b/Sources/SkipScript/JSContext.swift index 2cb660c..9a6639e 100644 --- a/Sources/SkipScript/JSContext.swift +++ b/Sources/SkipScript/JSContext.swift @@ -1,5 +1,6 @@ // Copyright 2023–2025 Skip // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception +#if !SKIP_BRIDGE #if !SKIP import Foundation // Non-Skip uses the JavaScriptCore symbols directly @@ -1361,3 +1362,4 @@ public let kJSPropertyAttributeDontEnum: JSPropertyAttributes = Int32(1) << 2 public let kJSPropertyAttributeDontDelete: JSPropertyAttributes = Int32(1) << 3 #endif +#endif