trustyfrog trustyfrog - 7 months ago 14
Swift Question

Why doesn't my Swift struct property appear in framework?

I have declared a Swift struct in a framework, like so:

public struct Thing {
var myProperty: String
}


I can access this in the framework tests without issue.

However, when I link to this framework in an iOS app only this appears in the header:

public struct Thing {
}


Any ideas?

Answer

The default access level is internal. You must mark your property as public if you want it to show up outside the module.

public struct Thing {
    public var myProperty: String
}
Comments