You must use immutable static variables. Unfortunately, classes only support computed properties using the class modifier โ the compiler throws an error indicating that class variables are not yet supported.
But in structures, you can create static data members:
struct Constants { static let myConstant = 5 }
and, of course, you do not need to instantiate, since an immutable static property can simply be obtained as:
Constants.myConstant
source share