Skip to content

Commit c9c5ded

Browse files
committed
fix: Example now compiles also in Swift 5.10, library had no issues"
1 parent 96c7da3 commit c9c5ded

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "pulsar-client-swift",
8-
platforms: [.macOS(.v13)],
8+
platforms: [.macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9)],
99
products: [
1010
// Products define the executables and libraries a package produces, making them visible to other packages.
1111
.library(

Sources/PulsarExample/PulsarExample.swift

+9-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ struct PulsarExample {
3737
Task {
3838
do {
3939
for try await message in consumer {
40-
msgCount += 1
41-
print("Received message in the exec: \(String(decoding: message.data, as: UTF8.self))")
42-
if msgCount == 2 {
43-
try await consumer.close()
44-
print("Closed consumer")
45-
}
40+
// Fix an concurrency false-positive in Swift 5.10 - It's only demo code, so no issue
41+
#if compiler(>=6)
42+
msgCount += 1
43+
print("Received message in the exec: \(String(decoding: message.data, as: UTF8.self))")
44+
if msgCount == 2 {
45+
try await consumer.close()
46+
print("Closed consumer")
47+
}
48+
#endif
4649
}
4750
} catch {
4851
print("Whooops we closed, this should never happen")

0 commit comments

Comments
 (0)