I'm trying to make a timetable app for my Apple Watch, and it has all actually been going pretty smoothly until this random error started showing up when I try to build my application. Here's a code snippet:
// all on top level:
class globalStorage {
static let shared = globalStorage() // line 27
@State @AppStorage(runningKey) var termRunningGB = false
@State @AppStorage(ghostWeekKey) var ghostWeekGB = false
@State @AppStorage(startDateKey) var startDateGB = Date.now
var currentCourse: Course = getCurrentClass(date: .now)
}
let storage = globalStorage.shared // << ERRORING HERE (line
// ...
@main
struct myApp: App { /* ... */ }
Can anybody tell me what is happening? (And, of course, how to fix it?)
Furthermore, upon removing the offending line (let storage = globalStorage.shared
) (and replacing all callers of said variable with 'globalStorage.shared' to bypass the variable) the error has decided to settle on line 27, where i define the 'shared' thing in the class.
[ I just went back to try more solutions, I have resolved it but forgot to give my solution here. Now I've forgotten how I fixed it. I do know that I moved currentCourse out of the class, that most likely was it I think.]
All of this code is on GitHub: https://github.com/the-trumpeter/Timetaber-for-iWatch