I have the next scenario :
I have created a Swift package that I am using in a main application. In this Swift Package I want to use some colors because it's an UI package. My struct Colors is already defined in my main application and I don't want to define it again in the package so I am trying to send my struct Colors to the package.
Also my struct Colors have another struct General in it like:
struct Colors {
struct General {
static let mainColor = "5F8E3F".toColor
}
}
This is how I call it in my package:
func setupContent(withMainStruct mainStruct: Colors) {
print(mainStruct.General.mainColor)
}
This is how I send it from main application:
let mainStruct = ColorStruct()
cell.setupContent(withMainStruct: mainStruct)
My main problem is:
Static member 'General' cannot be used on instance of type 'Colors'
Is there any way to do this?
All I want is to use the values of the struct, I don't need to update any of it.
Colors.General.mainColorwhy even bother to create an instance of Colors in first place? Error is pretty clear, you can not access static properties from an instance, so avoid it, access it directly throughColors.General.mainColorI am not really sure of your use case but looking at the way the structures are nested and has a static let seems you could take a better approach :|packageand the value to be sent from themain application