Nimble: Xcode 12 beta 5 and 6 build error `ambiguous use of 'expect'`
- I have read CONTRIBUTING and have done my best to follow them.
What did you do?
I installed Xcode 12 beta 5 and 6 and tried to build our existing (test) code:
it("should throw an error") {
expect {
try JSONDecoder().decode(SomeModel.self, from: data)
}.to(throwError())
}
What did you expect to happen?
I expected the code to compile.
What actually happened instead?
The code failed to compile with a ambiguous use of 'expect' error. With these two candidates:
- Sources/Nimble/DSL.swift#L1-L8
public func expect<T>(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation<T>
- Sources/Nimble/DSL.swift#L10-L17: Found this candidate
public func expect<T>(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation<T>
Environment
List the software versions you’re using:
- Quick: 2.2.1 + 3.0.0
- Nimble: 8.1.1 + 9.0.0-rc.1
- Xcode Version: 12.0 beta 5 (12A8189h), 12.0 beta 6 (12A8189n)
- Swift Version: Xcode Default
Please also mention which package manager you used and its version. Delete the other package managers in this list:
- Carthage: 0.35.0
Project that demonstrates the issue
https://github.com/rastersize/Xcode12Beta5Nimble
After cloning do the following:
- Run
carthage.sh bootstrap- The script works around a Carthage bug with Xcode 12 beta 4+ and universal binaries. As newer versions of Xcode 12 will produce an
arm64slice for both the simulator and device, and a universal binary can’t contain two slices for the same architecture.
- The script works around a Carthage bug with Xcode 12 beta 4+ and universal binaries. As newer versions of Xcode 12 will produce an
- Open the Xcode project
- Build for testing
Workaround
Change the call-site of expect to specify using the non-autoclosure function. That is:
it("should throw an error") {
expect(expression: {
try JSONDecoder().decode(SomeModel.self, from: data)
}).to(throwError())
}
Not as pretty but it works for now.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (5 by maintainers)
@ketenshi Another workaround I found is by adding
() -> ToSucceedResult inlike so:Not sure if this behaviour is expected in Nimble 9.
I’m on the same configuration and I’m getting a similar error,
Illegal instruction: 4, but always when evaluatingexpect{}.toEventually()Just released v9.0.0-rc.3 including the fix for this. Please try it!
That is due to #821 and I now understand that the change was not correct. I’ll revert it.
Could you please reorder arguments.
Adding
fileargument label should fix that:expect(file: file, ...).As a workaround, adding this function got my tests to run on Nimble 8.x using Xcode 12 GM.
@rastersize Exactly, those are not related to #820.
@sraiteri Good suggestion, I’ve updated the title and issue description. As well as the
SR.It seems like Xcode Beta 6 is near identical to Beta 5. Same version of
swiftcand almost no difference in build version for Xcode itself. Hopefully coming version will fix it 🤞