You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, the Zen Browser app (https://zen-browser.app) is able (registered to handle) to open HTML documents, but does not show up in the list. Same with Firefox. However, they do show up with LSCopyAllRoleHandlersForContentType(kUTTypeHTML, .viewer)?.takeRetainedValue() as? [String] ?? []. The former is documented as a replacement for the latter, but it seems they use different logic. I initially thought there was something wrong with my system, but I also got a report from a user on one of my apps that uses NSWorkspace.shared.urlsForApplications(toOpen: .html) that said Zen Browser was missing, so there is definitely something going on.
I have tried both in a sanboxed and unsandboxed app.
The missing apps live in /Applications, but same result if they are in ~/Applications. I have also tried turning Spotlight off and on again. And I have tried resetting lsregister. Restarting computer. Nothing helped.
The "default browser" setting in System Settings does include Zen Browser, so I have a feeling it is using the older API.
NSWorkspace.shared.urlsForApplications(toOpen: "https:") also does not return Zen Browser, even though the app registers to handle https and http schemes.
I have written a simple script to compare the output of these methods:
func compareHTMLHandlers(){
// Get URLs from NSWorkspace
letworkspaceURLs=NSWorkspace.shared.urlsForApplications(toOpen:.html)letworkspaceHandlers=Set(workspaceURLs.compactMap{ url ->String?inBundle(url: url)?.bundleIdentifier
})
// Get handlers from Launch Services
letlsHandlers=Set(LSCopyAllRoleHandlersForContentType(kUTTypeHTML,.viewer)?.takeRetainedValue()as?[String]??[])
// Find differences
letonlyInWorkspace= workspaceHandlers.subtracting(lsHandlers)letonlyInLaunchServices= lsHandlers.subtracting(workspaceHandlers)
// Print results
print("Only in NSWorkspace:")forbundleIDin onlyInWorkspace.sorted(){iflet appURL =NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID){print("- \(bundleID) (\(appURL.lastPathComponent))")}else{print("- \(bundleID)")}}print("\nOnly in Launch Services:")forbundleIDin onlyInLaunchServices.sorted(){iflet appURL =NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID){print("- \(bundleID) (\(appURL.lastPathComponent))")}else{print("- \(bundleID)")}}}compareHTMLHandlers()
The text was updated successfully, but these errors were encountered:
Description
For example, the Zen Browser app (https://zen-browser.app) is able (registered to handle) to open HTML documents, but does not show up in the list. Same with Firefox. However, they do show up with
LSCopyAllRoleHandlersForContentType(kUTTypeHTML, .viewer)?.takeRetainedValue() as? [String] ?? []
. The former is documented as a replacement for the latter, but it seems they use different logic. I initially thought there was something wrong with my system, but I also got a report from a user on one of my apps that usesNSWorkspace.shared.urlsForApplications(toOpen: .html)
that said Zen Browser was missing, so there is definitely something going on.I have tried both in a sanboxed and unsandboxed app.
The missing apps live in /Applications, but same result if they are in ~/Applications. I have also tried turning Spotlight off and on again. And I have tried resetting
lsregister
. Restarting computer. Nothing helped.The "default browser" setting in System Settings does include Zen Browser, so I have a feeling it is using the older API.
NSWorkspace.shared.urlsForApplications(toOpen: "https:")
also does not return Zen Browser, even though the app registers to handlehttps
andhttp
schemes.I have written a simple script to compare the output of these methods:
The text was updated successfully, but these errors were encountered: