Xcode warning: Immutable property will not be decoded because it is declared with an initial value which cannot be overwritten
问题 Running Xcode 12, my Swift 5 Xcode project now has warnings whenever a Decodable or Codable type declares a let constant with an initial value. struct ExampleItem: Decodable { let number: Int = 42 // warning } Immutable property will not be decoded because it is declared with an initial value which cannot be overwritten Xcode suggests changing the let to a var : Fix: Make the property mutable instead var number: Int = 42 It also suggests the fix: Fix: Set the initial value via the initializer