Extension of a nested type in Swift
It seems like this problem is related to SR-631. I've encountered similar a issue, I guess the complier is trying to process the file where you extend the nested class before the one where it's defined. Therefore you have this error saying that that A has no member B.
The solution I've found is to go to your target settings, open Build Phases
.
There, in Compile Sources
section you should put the file where you define the nested class above files where you extend it.
Update
The fix will be shipping with Xcode 10.2
this works in my playground, as expected
class A {
}
extension A {
class B {
}
}
extension A.B {
func foo() {
print("print from extension A.B")
}
}
let ab = A.B()
ab.foo() // print from extension A.B