9.4 C
London
Sunday, March 3, 2024

ios – SwiftUI/AppWindowsController.swift:89: Deadly error


Has anybody seen this error earlier than?

SwiftUI/AppWindowsController.swift:89: Deadly error

Seemed throughout Google and could not discover a lot on it. I am attempting to develop a easy menu bar app for macos and operating into this error at any time when I attempt to run my app. I am considering it could possibly be a bug with AppStorage however I am unsure. I’ve additionally set the Boolean key Utility is agent (UI Aspect) to ‘YES’ inside my Data.plist file. This key specifies the next as per apple docs:

LSUIElement (Boolean - macOS) specifies whether or not the app runs as an agent app. If this key's set to YES, Launch Providers runs the app as an agent app. Agent apps don't seem within the Dock or within the Pressure Stop window. Though they usually run as background apps, they'll come to the foreground to current a consumer interface if desired. A click on on a window belonging to an agent app brings that app ahead to deal with occasions.

I am additionally questioning if this key’s inflicting my app to crash with the error, however I’ve toggled the worth to YES and NO, and the app crashes with both worth set.

I am operating Xcode 15.2 with Swift 5.9.2. The minimal deployment model is MacOS 14.2.

Right here is my full utility code:

import SwiftUI

@essential
struct GiveMeTwentyApp: App {
    
    @AppStorage(SettingsKeys.showAppInMenuBar) var showAppInMenuBar: Bool = true
    
    var physique: some Scene {
        #if os(macOS)
        MenuBarExtra(isInserted: $showAppInMenuBar) {
            ContentView()
                .navigationTitle("GiveMeTwenty")
        } label: {
            Label("GiveMeTwenty", systemImage: "star")
        }
        .menuBarExtraStyle(.window)
        #endif
        
        WindowGroup {
            ContentView()
                .navigationTitle("GiveMeTwenty")
        }
    }
}
import Basis

enum SettingsKeys {
    static let reminderFrequency = "reminderFrequency"
    static let runWhenComputerStarts = "runWhenComputerStarts"
    static let showAppInMenuBar = "showAppInMenuBar"
    static let popUpMenuMessage = "popUpMenuMessage"
    static let notificationsEnabled = "notificationsEnabled"
}
import SwiftUI

struct ContentView: View {
    // Configure app to ship reminders each x hours
    @AppStorage(SettingsKeys.reminderFrequency) var reminderFrequency: Int = 1
    
    // Configure app to ship notifications or not
    @AppStorage(SettingsKeys.notificationsEnabled) var notificationsEnabled: Bool = true
    
    // Configure app to run when pc begins
    @AppStorage(SettingsKeys.runWhenComputerStarts) var runWhenComputerStarts: Bool = true
    
    // Configure app to seem in menu bar or not
    @AppStorage(SettingsKeys.showAppInMenuBar) var showAppInMenuBar: Bool = true
    
    // Configure message to point out on popUp Menu
    @AppStorage(SettingsKeys.popUpMenuMessage) var popUpMenuMessage: String = "Give Me Twenty!"
    
    non-public let reminderFrequencyOptions = [1, 2, 3, 4, 5, 6, 7, 8]
    
    var physique: some View {
        VStack(alignment: .main) {
            HStack {
                Picker("Each", choice: $reminderFrequency) {
                    ForEach(reminderFrequencyOptions, id: .self) {
                        Textual content($0.description)
                    }
                }
                .body(width: 80)
                .clipped()
                
                Textual content("hours take a break.")
                
            }
            .padding()
            
            Toggle(isOn: $notificationsEnabled) {
                Textual content("Allow notifications")
            }
            .toggleStyle(.checkbox)
            .padding()
            
            Toggle(isOn: $runWhenComputerStarts) {
                Textual content("Run when pc begins")
            }
            .toggleStyle(.checkbox)
            .padding()
            
            Toggle(isOn: $showAppInMenuBar) {
                Textual content("Present app in menu bar")
            }
            .toggleStyle(.checkbox)
            .padding()
            
        }
        .body(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
        .padding()
    }
}

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here