Posts

Post not yet marked as solved
3 Replies
11k Views
Since updating to Xcode 9.3, I can no longer run unit or UI tests on iOS apps. I've wiped Xcode and reinstalled it to no avail. To test it I created two new iOS projects from the single view template and included either unit or UI tests.When I run the tests, the build succeeds and launches the tests. For the UI tests, the test-runner crashes with an assertion failure trying to load a UITestUITests.xctest plugin, for unit tests, the test fails without running any tests complaining “Unable to initialize test bundle from file:///Users/…/UnitTest.app/PlugIns/UnitTestTests.xctest/”.These plugin files all exist.Radar #39236687
Posted Last updated
.
Post not yet marked as solved
0 Replies
633 Views
I’m finding Combine's Future publisher to useful as an API surface because by definition it produces zero or one values then finishes. If a function returns a future, the caller implictly knows it will only ever return a single value. I can use AnyPublisher and get essentially the same result, but I lose the self documenting aspect of supplying a single shot publisher.In some cases, I have a function consuming a future and returning a new future with an adjusted type. With a type like Result I can map one type to another, but Future.map returns a Publishers.Map type leading me back to AnyPublisher for my API. Is there a good way to map Future<Output, Failure> to Future<NewOutput, Failure>?Thanks,Nick* apologies for posting a beta framework related question in the language forum, but I can’t find a better place for it
Posted Last updated
.
Post marked as solved
4 Replies
2.8k Views
In recent Xcode 11 betas, Swift 5.1 has become more aggressive about releasing values assigned to the underscore. This means I must leave a warning in the code if I'm not using the value directly, but expecting a side effect (e.g., with Combine).For example, the following unit test passes, but contains the warning on line 6: "Initialization of immutable value 'unusedButNeeded' was never used; consider replacing with assignment to '_' or removing it."func testPassthroughSubjectSequence() { let expectedResult = [1, 2, 3] var actualResult: [Int] = [] let subject = PassthroughSubject<Int, Never>() let unusedButNeeded = subject.sink { actualResult.append($0) } for value in expectedResult { subject.send(value) } XCTAssertEqual(actualResult, expectedResult) }However, if I take the advise of the warning and change that line to assign to '_' the test fails because the value is released before the closure is invoked. This worked in earlier compiler versions because apparently the release was delayed._ = subject.sink { actualResult.append($0) }Is there some way to suppress this warning, or prevent the new aggressive release behavior in this case?Thanks,Nick
Posted Last updated
.