Add support for macOS
Thank you for this! I used this in a multiplatform test project. I needed to change a few things for macOS support.
- Change package platforms to support Catalina and above
- Add macOS availability annotation with deprecation for Monterey
- Adjust showView helper for running tests on macOS
I also noticed that some of the tests are flaky with Xcode 13.2 on 11.6.2. It can be reproduced easily with the repeated tests feature in Xcode.
Example:
let subject = PassthroughSubject<Int, Never>()
let valueTask = Task<[Int], Never> {
var values = [Int]()
for await value in subject.values {
values.append(value)
}
return values
}
Task {
subject.send(1)
subject.send(2)
subject.send(3)
subject.send(completion: .finished)
}
let values = await valueTask.value
XCTAssertEqual(values, [1, 2, 3])
Mac (11.6.2) as test platform:
Test Suite 'AsyncCompatibilityKitTests.xctest' failed at 2021-12-22 15:37:33.281.
Executed 100 tests, with 20 failures (0 unexpected) in 5.906 (6.114) seconds
It seems that the Task that sends the values and the finish event to the subject might run before the valueTask and then only the completion is received resulting in an empty array. Adding a short Task.sleep before sending the values fixes this as a workaround. I'm still learning how the new swift concurrency works. But I'm not sure about any guarantees for the order of execution of the two Task { } blocks here. The PassthroughSubject will drop values, if there's no subscriber yet.
Testing repeatedly on iOS simulators with iOS 13.7 or 14.5 also fails.
Thank you for this library. Is there a chance this PR will get merged?
A nice weekend to everyone!