1

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?

iProgram
  • 6,057
  • 9
  • 39
  • 80

1 Answers1

3

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:

enter image description here

Bryan Luby
  • 2,527
  • 22
  • 31
  • Since I find it harder looking at Apples API use could you tell me how to make it an option in 'System Preferences'. By this I mean could you show me how to make it a setting in System Preferences -> General -> Set default web browser. And also how would I check the url that has been opened? Thanks. – iProgram Dec 21 '14 at 20:44
  • Thanks for showing me how to add it as a default web browser however what would the code be to get the url? What i mean is if an application wants to open www.google.com how would I find that? Thanks. – iProgram Dec 22 '14 at 11:03
  • @aPyDeveloper That is a separate issue that will require creating a separate question. – Bryan Luby Dec 22 '14 at 13:38
  • What is the solution for iOS. I mean, whats the solution if I want my iOS app to be detected as a browser? – Vaibhav Jhaveri Sep 30 '16 at 07:13
  • Although the app became a default browser it didn't appear under System Preferences... anymore on macOS 11 (Bug Sur), but was able to solve it following the additional steps on: https://stackoverflow.com/a/65479328/4691224 – vicegax Dec 28 '20 at 14:46