我有下一个场景:
我创建了一个Swift package
我正在使用的main application
. 在这Swift Package
我想使用一些颜色,因为它是一个UI package
. 我struct Colors
的已经是defined in my main application
,我不想在 中再次定义它,package
所以我试图将我struct Colors
的package
.
我struct Colors
还有另一个struct General
像:
struct Colors {
struct General {
static let mainColor = "5F8E3F".toColor
}
}
这就是我在我的package
:
func setupContent(withMainStruct mainStruct: Colors) {
print(mainStruct.General.mainColor)
}
这就是我发送它的方式main application
:
let mainStruct = ColorStruct()
cell.setupContent(withMainStruct: mainStruct)
我的主要问题是:
Static member 'General' cannot be used on instance of type 'Colors'
有没有办法做到这一点?
我想要的只是使用结构的值,我不需要更新它。