I guess, based on the code you posted, that you are trying to “forward-declare” your init and bar methods.
There are no forward declarations in Swift.
Because Foo is a class, it can have two kinds of init: “designated” and “convenience”. All designated inits need to be defined in the main body of Foo, and you must have at least one designated init. You can put convenience inits and other methods in extensions. For example:
class Foo {
var x: Int
// Note that this is a designated init because it doesn't have the
// `convenience` keyword.
init() {
x = 0
}
}
extension Foo {
convenience init(v: Int) {
self.init()
x = v
}
}
extension Foo {
func bar() -> Int {
return x
}
func bar(u:Int, v:Int) -> Int {
return x + u + v
}
}
This has to do with access control; basically, an init has to initialise all the storage of a type, including private properties. Since private properties aren't visible from a different file, the init has to be in the same file. Moreover, because extensions can be "many", while the type definition is "one", requiring a designated init in the type declaration eliminates potential collisions, where multiple extensions try to write the same init. This is important for classes, because all that class's subclasses need to know which of its inits are designated so that they can call super.init on them.
Otherwise, the lack of forward declarations is actually a manifestation of a modern language, since the code duplication due to forward declarations and headers was (is) quite an annoyance in the older C-like languages.
That seems like a job for the text editor/IDE level. It's also duplicating information, so you have to jump back and forth to keep it all in sync. Why waste human effort to generate interfaces for presentation like this, when a machine can prepare it automatically?
Ironically, the split header+implementation structure of C/C++ programs is often cited as one of the biggest factors that make them feel "old".