6

Target OS: Macos 10.15.3 Catalina

Goal: use apple script bundled to app as a default web browser

To debug I'm using very simple apple script, that just show passed url in dialog

on open location theURL
    display dialog "Passed url : " & theURL
end open location

I also added CFBundleURLTypes to Info.plist to claim binding to http\https url schemas

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>My test app url</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>http</string>
                <string>https</string>
            </array>
        </dict>
    </array>

The problem: is that app is not showing up in 'Default web browser' combobox in System Preferences -> General

I've tried to dump Launch Service database /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

And my app is present there.

Also tried force register /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f ./MyTestApp.app

Also tried to sign my app by self issued signature.

Nothing helped.

What could I miss? Is there any additional configurations that should be done to let macos recognize my apple scrip app as possible default browser?

4
  • Have you run your app ? That is, did you save it, then double-click on it the .app bundle ?
    – CJK
    Apr 7, 2020 at 0:52
  • Of course I've have run it. And as I mentioned it was registered in Launch Service database, i.e. I see my app in its dump. In other words macos is aware of my application but for some reason not allow to choose it as a default browser Apr 7, 2020 at 9:09
  • Did you ever figure this out? I'm on Ventura and I've just done something similar that successfully handles mailto links but I don't seem to be able to make it work for http/https 🤔
    – Matthew
    Feb 9, 2023 at 15:47
  • Update It just started working for me. Like you it was showing up in Launch Services but not the browser chooser. To test the app standalone I removed the "on open location theURL" block and saved it. When I added it back in and saved it again it immediately showed up in the list of available browsers and started working 🤷‍♂️ If that works for you too I can try and write it up as an answer
    – Matthew
    Feb 9, 2023 at 16:11

3 Answers 3

1

I do not think that you can build a browser like that, but I do know that there is a very simple browser out that which will take whatever URL it is sent and pass it to the clipboard:

https://github.com/alistairmcmillan/short/tree/master/Copy%20URL%20to%20Clipboard

Perhaps that might help.

2
  • I don't wanna build a browser I want an app that can be assigned as default handler for http\https url schemas. As I understand the app build from apple script is just an app as many others and I don't see any reason why it can't be a default handler for http\https. As I can judge app shouldn't be a real browser to be selected as default browser(just because I can choose evernote app, video player, or even iTerm as a default browser(i.e. default handler for http)). Looks like the matter in configuration. Therefore the question is how properly configure my app. Apr 8, 2020 at 10:09
  • I understand what you want. What I'm saying is that I don't think it can be done the way that you want it to be done. I'd be happy to be proven wrong, but I've never seen anything that suggests that what you want can be done the way you want to do it. All of the examples that you give are…apps… not AppleScript wrappers exported as an app.
    – TJ Luoma
    Apr 11, 2020 at 17:30
0

Can’t guarantee this, but here’s what I would try:

  1. Create a .webloc on the desktop, pointing to any URI.
  2. Select it, Get Info, and change its application to your desired default. You’ll have to change “suggested apps” to “other” to be able to do it.
  3. Check the box to do it for all files of this type.
1
  • It won't help since it set default application for .webloc file type not for http\https url schemas, what is originally desired Apr 7, 2020 at 9:15
0

I solved it by also adding document types for HTML and XHTML to the Info.plist, like this:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>HTML document</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.html</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>XHTML document</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.xhtml</string>
        </array>
    </dict>
</array>
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>Web site URL</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>http</string>
            <string>https</string>
        </array>
    </dict>
</array>
3
  • Welcome to Ask Different! Your answer would be so much more useful if you'd add additional information on explicitly and specifically how/what to do with what you posted. Please consider improving your answer by editing in the missing information. Dec 28, 2020 at 14:02
  • @user3439894 the information is already there, maybe is not clear enough?; this is what I added to the Info.plist file in order to be selectable for Default browser. Dec 28, 2020 at 14:33
  • You have missed the point entirely! You should provide the information and steps necessary to actually add it to the Info.plist file. This includes where the file resides and how to edit it so as not to damage it! Dec 28, 2020 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .