From b440f7bae8894b5ec42e0f1842fcd77483ab3984 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Mon, 9 Nov 2026 10:17:46 +0100 Subject: [PATCH] Guard `autoreleasepool` with `canImport(ObjectiveC)` (#3782) The `autoreleasepool` code only needs the `ObjectiveC` runtime, not `Darwin`. --- Sources/NIOPosix/SelectableEventLoop.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/NIOPosix/SelectableEventLoop.swift b/Sources/NIOPosix/SelectableEventLoop.swift index a0ca38684..87aa04375 100644 --- a/Sources/NIOPosix/SelectableEventLoop.swift +++ b/Sources/NIOPosix/SelectableEventLoop.swift @@ -22,6 +22,10 @@ import NIOConcurrencyHelpers import NIOCore import _NIODataStructures +#if canImport(ObjectiveC) +import ObjectiveC +#endif + private func printError(_ string: StaticString) { string.withUTF8Buffer { buf in var buf = buf @@ -41,7 +45,7 @@ private func printError(_ string: StaticString) { /// Execute the given closure and ensure we release all auto pools if needed. @inlinable internal func withAutoReleasePool(_ execute: () throws -> T) rethrows -> T { - #if canImport(Darwin) + #if canImport(ObjectiveC) return try autoreleasepool { try execute() }