问题
I am currently trying to make a web browser (for OS X) using swift. I have found tutorials on how to make one however I do not know how to make it as my default web browser. Is there a way I can do this?
回答1:
Use the Launch Services API to manually set the default handler for the http URL scheme:
LSSetDefaultHandlerForURLScheme("http", "com.ORGANIZATION.APPNAME")
Additionally, to expose the app as a default browser setting under System Preferences > General > Set default web browser, add a URL type in the info tab of the Xcode project. Make sure to add an Identifier and the "http" URL Scheme. Build and run:
来源:https://stackoverflow.com/questions/27314938/swift-set-as-default-web-browser