You are right. It should be OK to use let
here.
I wasn't very sure about this so I asked ChatGPT and I got:
You're right that the
defaultValue
in thePreferenceKey
protocol is declared as avar
, and changing it to alet
would indeed break the protocol conformance. The warning about concurrency is becausestatic
properties in Swift are shared across all threads, and mutable shared state can lead to race conditions.