From 170ff513458a81dd41cc94aa8dadabb9842e9698 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 24 Mar 2022 20:12:30 +0900 Subject: [PATCH 1/2] Use availablility guarded APIs under available attr for Xcode development Co-authored-by: Valeriy Van --- Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift | 4 ++++ Sources/JavaScriptEventLoop/JobQueue.swift | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift b/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift index 8a163b11f..b68889c42 100644 --- a/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift +++ b/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift @@ -1,8 +1,11 @@ import JavaScriptKit import _CJavaScriptEventLoop +// NOTE: `@available` annotations are semantically wrong, but they make it easier to develop applications targeting WebAssembly in Xcode. + #if compiler(>=5.5) +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { /// A function that queues a given closure as a microtask into JavaScript event loop. @@ -94,6 +97,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { } } +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) public extension JSPromise { /// Wait for the promise to complete, returning (or throwing) its result. var value: JSValue { diff --git a/Sources/JavaScriptEventLoop/JobQueue.swift b/Sources/JavaScriptEventLoop/JobQueue.swift index 5030a6ca7..56090d120 100644 --- a/Sources/JavaScriptEventLoop/JobQueue.swift +++ b/Sources/JavaScriptEventLoop/JobQueue.swift @@ -5,11 +5,14 @@ import _CJavaScriptEventLoop #if compiler(>=5.5) + +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) struct QueueState: Sendable { fileprivate var headJob: UnownedJob? = nil fileprivate var isSpinning: Bool = false } +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) extension JavaScriptEventLoop { func insertJobQueue(job newJob: UnownedJob) { @@ -55,6 +58,7 @@ extension JavaScriptEventLoop { } } +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) fileprivate extension UnownedJob { private func asImpl() -> UnsafeMutablePointer<_CJavaScriptEventLoop.Job> { unsafeBitCast(self, to: UnsafeMutablePointer<_CJavaScriptEventLoop.Job>.self) From bc8557c967e140ecafa765849805c348bdfcb7de Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 24 Mar 2022 20:19:49 +0900 Subject: [PATCH 2/2] Add ci job to check Xcode compatibility --- .github/workflows/test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1562e06d..b3992b7dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,3 +26,12 @@ jobs: SWIFT_VERSION=${{ matrix.toolchain }} make bootstrap echo ${{ matrix.toolchain }} > .swift-version make test + native-build: + # Check native build to make it easy to develop applications by Xcode + name: Build for native target + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + - run: swift build + env: + DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer/