Search code examples
swiftunit-testing

Why am I getting has no member error


Sorry if this is an easy one, but I'm spinning up on Swift 3 and I'm just stuck.

I created my Swift 3 class and a unit test for it. I'm now adding a new method and want to write a unit test for it:

public func isEmpty() -> Bool {
    return false
}

Then I went to my unit test and wrote the following:

func testPersist() {
    XCTAssertFalse(currentQuote.isEmpty())
}

But the assert gets an error saying: Value of type CurrentQuote has no member 'isEmpty'

I found these questions, but they don't seem to help me:

Swift - Type has no member "classname has no member functionname" when adding UIButton target

I'm sure this is something basic, but I just can't figure it out.


Solution

  • I think it's just a timing error. I ran the test to force a build and it ran fine. I think the executable hadn't been updated since I added the method and it was still showing as missing.