Skip to content

Commit cea89ce

Browse files
author
Josh Wright
authored
Switch up compiler directives for concurrency (#111)
* Switch up compiler directives for concurrency
1 parent 2744df5 commit cea89ce

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Sources/Lifecycle/Lifecycle.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#if compiler(>=5.5)
16-
import _Concurrency
17-
#endif
18-
1915
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
2016
import Darwin
2117
#else
@@ -99,7 +95,7 @@ public struct LifecycleHandler {
9995
}
10096
}
10197

102-
#if compiler(>=5.5)
98+
#if compiler(>=5.5) && canImport(_Concurrency)
10399
@available(macOS 12.0, *)
104100
extension LifecycleHandler {
105101
public init(_ handler: @escaping () async throws -> Void) {
@@ -163,7 +159,7 @@ public struct LifecycleStartHandler<State> {
163159
}
164160
}
165161

166-
#if compiler(>=5.5)
162+
#if compiler(>=5.5) && canImport(_Concurrency)
167163
@available(macOS 12.0, *)
168164
extension LifecycleStartHandler {
169165
public init(_ handler: @escaping () async throws -> State) {
@@ -225,7 +221,7 @@ public struct LifecycleShutdownHandler<State> {
225221
}
226222
}
227223

228-
#if compiler(>=5.5)
224+
#if compiler(>=5.5) && canImport(_Concurrency)
229225
@available(macOS 12.0, *)
230226
extension LifecycleShutdownHandler {
231227
public init(_ handler: @escaping (State) async throws -> Void) {

Tests/LifecycleTests/ComponentLifecycleTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,8 @@ final class ComponentLifecycleTests: XCTestCase {
14031403
return
14041404
#elseif compiler(<5.5)
14051405
throw XCTSkip()
1406+
#elseif !canImport(_Concurrency)
1407+
throw XCTSkip()
14061408
#else
14071409
guard #available(macOS 12.0, *) else {
14081410
throw XCTSkip()
@@ -1437,6 +1439,8 @@ final class ComponentLifecycleTests: XCTestCase {
14371439
return
14381440
#elseif compiler(<5.5)
14391441
throw XCTSkip()
1442+
#elseif !canImport(_Concurrency)
1443+
throw XCTSkip()
14401444
#else
14411445
guard #available(macOS 12.0, *) else {
14421446
throw XCTSkip()
@@ -1475,6 +1479,8 @@ final class ComponentLifecycleTests: XCTestCase {
14751479
return
14761480
#elseif compiler(<5.5)
14771481
throw XCTSkip()
1482+
#elseif !canImport(_Concurrency)
1483+
throw XCTSkip()
14781484
#else
14791485
guard #available(macOS 12.0, *) else {
14801486
throw XCTSkip()
@@ -1511,6 +1517,8 @@ final class ComponentLifecycleTests: XCTestCase {
15111517
return
15121518
#elseif compiler(<5.5)
15131519
throw XCTSkip()
1520+
#elseif !canImport(_Concurrency)
1521+
throw XCTSkip()
15141522
#else
15151523
guard #available(macOS 12.0, *) else {
15161524
throw XCTSkip()
@@ -1547,6 +1555,8 @@ final class ComponentLifecycleTests: XCTestCase {
15471555
return
15481556
#elseif compiler(<5.5)
15491557
throw XCTSkip()
1558+
#elseif !canImport(_Concurrency)
1559+
throw XCTSkip()
15501560
#else
15511561
guard #available(macOS 12.0, *) else {
15521562
throw XCTSkip()

0 commit comments

Comments
 (0)