Post

Replies

Boosts

Views

Activity

Reply to Safari Extension: Please make sure your manifest.json file contains valid syntax
Today, I was developing Safari plug-ins and encountered this problem. It took me an hour to fix the problem. This is the code generated by the Xcode creation project. {   "manifest_version": 2,   "default_locale": "en",   "name": "__MSG_extension_name__",   "description": "__MSG_extension_description__",   "version": "1.0", // Note here that all image sizes must be present, do not delete any   "icons": {     "48": "images/icon-48.png",     "96": "images/icon-96.png",     "128": "images/icon-128.png",     "256": "images/icon-256.png",     "512": "images/icon-512.png"   },   "background": {     "scripts": [ "background.js" ],     "persistent": false   },   "content_scripts": [{     "js": [ "content.js" ],     "matches": [ "*://example.com/*" ]   }],   "browser_action": {     "default_popup": "popup.html", // Note here that all image sizes must be present, do not delete any     "default_icon": {       "16": "images/toolbar-icon-16.png",       "19": "images/toolbar-icon-19.png",       "32": "images/toolbar-icon-32.png",       "38": "images/toolbar-icon-38.png",       "48": "images/toolbar-icon-48.png",       "72": "images/toolbar-icon-72.png"     }   },   "permissions": [ ] }
Aug ’22
Reply to Big Sur: Detect when menu bar is light/dark
Recently I also encountered this problem, my solution is as follows, work for me swift let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) guard let button = statusItem.button else {       return } button.image = NSImage(named: "console") button.image?.isTemplate = true The previous solution, but there are still problems in Big Sur: swift var isDarkMode:Bool {UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark"} let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) func listenToInterfaceChangesNotification() {     DispatchQueue.main.async { [self] in       DistributedNotificationCenter.default.addObserver(         self,         selector: #selector(interfaceModeChanged(sender:)),         name: .AppleInterfaceThemeChangedNotification,         object: nil       )     }   } @objc func interfaceModeChanged(sender: NSNotification) { guard let button = statusItem.button else { return }       if(isDarkMode) { button.image = NSImage(named: "console_light") } else { button.image = NSImage(named: "console") } } isTemplate | Apple Developer Documentation https://developer.apple.com/documentation/appkit/nsimage/1520017-istemplate
Mar ’21