Trouble Implementing Custom Touch Bar in macOS 13.6 - Buttons configuration guide
After trying multiple solutions online, I still can't figure this out. I'm trying to implement a custom Touch Bar for my macOS app, but I'm working with issues where the buttons I add aren't responding to clicks. I have set up my NSTouchBar and added a couple of NSCustomTouchBarItem instances, but when I run the app, tapping the buttons does nothing. Here's a snippet of my setup: ```swift class MyViewController: NSViewController, NSTouchBarDelegate { override func viewDidLoad() { super.viewDidLoad() // Additional setup } override func makeTouchBar() -> NSTouchBar? { let touchBar = NSTouchBar() touchBar.delegate = self touchBar.defaultItemIdentifiers = [.button1, .button2] return touchBar } func touchBar(_ touchBar: NSTouchBar, itemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? { switch identifier { case .button1: let item = NSCustomTouchBarItem(identifier: identifier) item.view = NSButton(title: "Button 1", target: self, action: #selector(button1Tapped)) return item case .button2: let item = NSCustomTouchBarItem(identifier: identifier) item.view = NSButton(title: "Button 2", target: self, action: #selector(button2Tapped)) return item default: return nil } } @objc func button1Tapped() { print("Button 1 tapped") } @objc func button2Tapped() { print("Button 2 tapped") } } ``` The buttons don't show any visual feedback when tapped, and the print statements are never executed. I've tried checking the identifiers and ensuring the actions are correctly linked, but nothing seems to work. I also verified that the app has the appropriate permissions, and the Touch Bar is enabled in the System Preferences. Has anyone faced similar issues or could provide insights on what might be going wrong? Any help would be greatly appreciated! I'm working with Swift in a Docker container on Ubuntu 20.04. I'm open to any suggestions. For reference, this is a production microservice.