Through the process of elimination I have discovered that I will receive this error message if I include the “Spacer()” SwiftUI function within the main view master.
Post
Replies
Boosts
Views
Activity
This is occurring for me as well. My application still ran fine under the tvOS beta however now with the Xcode 12 GM and tvOS 14 GM it crashes upon launch. Did you ever find a resolution to this problem?
I also wanted to throw in my two cents on this topic. I currently am developing a SwiftUI based Mac app that does not use Catalyst so UIMenuBuilder is not an option. My solution was to create a new MainMenu.xib file (which would allow me to graphically manage the menu bar) and link it up by creating a NSApplicationDelegate in my application's main SwiftUI file. Within my newly created AppDelegate I pointed it towards the MainMenu.xib file that I had previously created.
Here is my example:
import SwiftUI
@main
struct SidebarApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var window: NSWindow!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let nib = NSNib(nibNamed: NSNib.Name("MainMenu"), bundle: Bundle.main)
nib?.instantiate(withOwner: NSApplication.shared, topLevelObjects: nil)
}
func applicationWillTerminate(_ aNotification: Notification) {
}
}
Once this is setup I was able to add/remove any Menu Bar item in a graphical way from the xib file. It is worth noting that this will override any Menu Bar items that were declared within the application itself. For me this was not too big of a deal as I would gladly recreate these items if it allowed me to simply remove the Help menu...
I cannot begin to thank you! This worked perfectly! It was so simple, I do not know why I didn't think of it. It throws a few errors in the console however the applicaiton works perfectly. It's like I can have my cake and eat it too...