Hi there! I'm new to Swift and I'm currently learning by reading the documentation. I'm now reading the Type Property Syntax part of the Properties chapter, but I encountered some issues.
I'm trying to run the code snippet provided in the documentation:
struct SomeStructure {
static var storedTypeProperty = "Some value."
static var computedTypeProperty: Int {
return 1
}
}
But I got an error from Xcode Static property 'storedTypeProperty' is not concurrency-safe because it is nonisolated global shared mutable state
I asked Google Gemini and Claude about it and they said that it's the documentation out of date because in Swift 6, there's an enforced-by-default strict concurrency protection so that it's not allowed to have such global type property. I switched the build language for my Playground from Swift 6 to Swift 5 and the error is gone and the code can be built.
But I'm still curious that is it actually the documentation outdated? Because it's been almost two years since the release of Swift 6 and no one is updating the docs? I also searched in the swift-book GitHub repo and I found nothing about this content. I don't believe this can be left undiscussed for so long.
So is it actually the documentation outdated, or am I doing anything wrong? I'm really confused because I'm new to Swift, and I can't believed that it can be the problem of the documentation that is remained unfixed for so long. Can anyone help explain this to me! I would deeply appreciate it!