I'm making a swift package using existing code to separate a class as a module from the main project.
My original code makes properties private(set)
, which is intended to make it only readable (not settable).
// Original code
// A property of the class
@Published private(set) var index: Int = 0
But Xcode reports an error 'index' is inaccessible due to 'internal' protection level
. I assume I have to change the private(set)
into public
. But I also want to protect it from editing outside of the class, which means still using private(set)
. Is there any syntax to do it?