seanhenry / SwiftMockGeneratorForXcode

An Xcode extension (plugin) to generate Swift test doubles automatically.
MIT License
748 stars 47 forks source link

Extensions not supported #51

Closed johnrnyquist closed 3 years ago

johnrnyquist commented 3 years ago

I've tried this in Xcode 12.4 and AppCode 2020.3.4. It appears extensions are not supported, so this is a feature request to add support for extensions.

Notice when I attempt to create FooSpy, the extension to Foo is ignored.

class Foo {
    func faa(){ }
}
extension Foo {
    func laa() { }
}

class FooSpy: Foo {

    var invokedFaa = false
    var invokedFaaCount = 0

    override func faa() {
        invokedFaa = true
        invokedFaaCount += 1
    }
}
johnrnyquist commented 3 years ago

Ah never mind... I see the issue is that in Swift we cannot override non-@objc declarations from extensions, so neither can MockGenerator.