-
-
Notifications
You must be signed in to change notification settings - Fork 143
Description
It appears someone published a similar issue to this, but didn't respond when macOS 13 was retail released: #106
The example remains the same from that issue - in fact that issue is still directly happening exactly as described. With the issue Wouter01 was having being nearly identical in setup to mine.
Attempting to use @Default
will break the app and lock it into a state loop:
@main
struct AutoClickerApp: App {
@Default(.menuBarShowIcon) private var menuBarShowIcon
var body: some Scene {
MenuBarExtra(isInserted: $menuBarShowIcon,
content: { Label("Hi!") },
label: { Image(systemName: "cursorarrow.click.2") })
.menuBarExtraStyle(.menu)
}
}
However to provide more insights into the issue, here is the exact error message being given:
2023-07-03 00:27:25.238937+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.240590+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.244646+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.245899+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.249397+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.250887+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.255733+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
2023-07-03 00:27:25.257386+0100 AutoClicker[8113:47383804] [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
This will hang the app as soon as the main window loads and is pulled into focus, with the app entering a state loop, with the debug console being spammed with the above error message.
With Xcode's debugger pointing at this line of code as the culprit:
https://github.com/sindresorhus/Defaults/blob/main/Sources/Defaults/SwiftUI.swift#L16
With a screenshot for reference within Xcode:
Although knowing Xcode, that probably isn't the source of the issue...
I'm not really sure how to debug this, so I can't really provide any insights beyond surfacing the problem I'm afraid, although I'll try to assist the best I can.