Swift 5.6.2 / Ubuntu 20.04.4: "expression failed to parse: error: Couldn't lookup symbols: XCTest.XCTAssertEqual"

XCTAssertEqual(1, 1, "")

expression failed to parse:
error: Couldn't lookup symbols:
  XCTest.XCTAssertEqual<τ_0_0 where τ_0_0: Swift.Equatable>(_: @autoclosure () throws -> τ_0_0, _: @autoclosure () throws -> τ_0_0, _: @autoclosure () -> Swift.String, file: Swift.StaticString, line: Swift.UInt) -> ()

XCTAssertEqual is defined in XCTest and should exist if you import XCTest

Could you please provide a bit more information about your project configuration? Best would be a self containing SwiftPM Package e.g. hosted on GitHub.
Complete code sample and instructions how you compile the code would also work :)

Is the complete code I entered into the REPL.

I don't think XCTest is available in the REPL

You try it for yourself then.

I have, it did not work. On macOS I got

expression failed to parse:
error: repl.swift:1:8: error: no such module 'XCTest'
import XCTest

I've created XCTest is not available in the REPL · Issue #60335 · apple/swift · GitHub to track this, but let me know if you've seen this reported before, I'll close as a duplicate then.

1 Like

I think what @Ilias_Karim is trying to say is that he's seeing a different error on Ubuntu (where, of course, XCTest is the corelibs version).

Yeah I suspect it's because on macOS the Objective-C XCTest runtime is present on the system and implicitly available to Swift, but not intended to be used with the REPL. On Linux it's not there so there's nothing to reference until link time when compiling tests. I guess the question is what do you expect to see?

Wouldn't we expect XCTest to "just work" in the Swift REPL in both cases?

1 Like