I found this Property Wrapper when searching for the Swiftiest way to get rid of the compiler warning. I assumed that Apple would have created a simple construct to resolve the warning since SwiftUI relies on the ID property of objects. But I didn't find an Apple resolution.
This one by iuriimoz on StackOverflow.
But then I got more warnings about Equatable and Hashable. Which is all about the ID property... so the solution is leading to bigger problems. I decided to make the ID property a variable - the simplest thing that could work.
let var id
But then trying that simple fix... well I get a happy compiler - but a sad App - as the Quote is no longer Decodable. If it ain't one thing - it's another!
This warning is driving me to ruin!
It seems this warning has been in contention in the Swift community since way back - StackOverflow Issue.
Yeah - but that didn't work out...
Maybe I wrapped the wrapping paper the wrong way... maybe counter-clockwise...
Reference: Ignore varibles for Equatable Conformance | by Dhaval Shreyas on Medium
I've been living with this warning for a week or more... trying to ignore it and keep moving on with life & coding. But I'm back. Searching for a solution. Because after compiling and running my App the editor switches to one of the files that have the stupid Warning:
"Immutable property will not be decoded because it is declared with an initial value which cannot be overwritten"
"Make the property mutable instead"
Switching away from my context - to that of the warning I'm trying to ignore - makes me just a touch angry. And the anger builds. Time to fix it!
References:
Apple Developer forum - doesn't really explore the realm ...
Swift forum has a possible working (questionable) answer
Customizing Codable types in Swift - by Sundell - I like this article it has a whole section on ignoring properties ... so thats how it is done!
Fixing issues with Codable identifiers - offers ONE solution: mutable id, and custom init(...)
[Answer] - how to get rid of the let id = UUID() error - uses the ONE solution - custom CodingKeys{ ... }
By The Way - did you know that Enum Name is Special - it's got magic wrapped around the name NOT the Type.
Note: The enum is called CodingKeys and the protocol is called CodingKey.
Codable Cheat Sheet - Hacking with Swift - but does not cover the id property issue.
And another thing... why do people do this:
let id = UUID().uuidString
setting identifiers using UUID's String as the value?
So I went for the hand-rolled
enum CodingKeys: CodingKey { ... }
Not hard - just tedious and error-prone.