suppose framework Foo has (sadly public) class Foo and a public struct Account
func fetchClient(guid: String) -> Foo.Account? {
yields a compiler error
'Account' is not a member type of class 'Foo.Foo'
What's the proper syntax to access (public) Account outside Foo? (Lots of swearwords about class aliased to framework here)
There is no such syntax yet. See also this discussion on Swift Forums which is discussing this exact issue.
As a workaround, you can import just the Account
struct from Foo
:
import struct Foo.Account
Now you won't see the class Foo
and you can say Foo.Account
.
If you also need the class Foo
, or lots of other things in Foo
, you can put a type alias for Foo.Account
in a separate file, using the above technique.
// this is the entirety of the file:
import struct Foo.Account
typealias FooAccount = Account
Also, there is a module alias feature that allows you to rename Foo
to something else, if you are using SPM. See the Swift Evolution Proposal.