3

Xcode Cloud fails to run some of my tests. Looks like it does not recognize the fulfillment(of:timeout:enforceOrder:) method.

Xcode error

The error I am getting is:

Cannot find 'fulfillment' in scope

The triggering code is very simple and when run locally, all is green. I changed the names of the variables but it looks like this:

func testThatFooThrows() async throws  {
  // GIVEN
  let expectation = expectation(description: "Expect to throw error")

  let fooMock = FooMock<Bar>()
  fooMock.failWithBadUrlError()

  let sut = FooService(contentID: "Test", myService: fooMock)

  // WHEN
  do {
      _ = try await sut.doSomething()
  } catch {
      expectation.fulfill()
  }

  // THEN
  await fulfillment(of: [expectation], timeout: 0.1)
}

Everything seems to work when I change the failing line to:

wait(for: [expectation], timeout: 0.1)

enter image description here

Instance method 'wait' is unavailable from asynchronous contexts; 
Use await fulfillment(of:timeout:enforceOrder:) instead; 
this is an error in Swift 6

However, as the warning says, this is not the best.

The documentation says that the fulfillment(of:timeout:enforceOrder:) method is available starting with Xcode 11. My Xcode Cloud setup uses Xcode 14.3.1 (14E300c) and macos Ventura 13.5 (22G74)

How can I make Xcode Cloud "see" the fulfillment(of:timeout:enforceOrder:) method?

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143

0 Answers0