Register default application
lazarus / 33-macOS - Mac OS X
----------------------------------------------------------------------
Ove Halseth · 2017-04-19 13:11
Hi,
Is it any way to programatically register a default application for a
custom file-ending?
So that .wiskrypt files is opened by my application.
Found this page that describes how to do it manually:
http://www.bittbox.com/os-x/how-to-set-the-default-program-to-open-a-
certain-type-of-file-in-mac-os-x
Ove B-)
----------------------------------------------------------------------
Phil · 2017-04-19 14:17
Quote from: Ove Halseth on April 19, 2017, 03:11:33 pmIs it any way to
programatically register a default application for a custom file-
ending?
You do that in your app's Info.plist file. Since Lazarus does not
provide any way to edit that in the IDE, you'll need to edit the
Info.plist with a text editor. See any app's Info.plist to see how
they associate a file type with an app action (for example, see how
Lazarus does it). See also Apple's docs on the subject.
You may also find this page helpful with other Mac related questions:
https://macpgmr.github.io/MacXPlatform/LazXProj.html
----------------------------------------------------------------------
Hansaplast · 2017-04-19 14:19
Maybe these articles help:
Apple Dev document (written for iOS but seems applicable for macOS as
well - reference): Registering the File Types Your App Supports
I found at least 2 more related topics at StackExchange:
- overriding Mac app file associations via CFBundleDocumentTypes in
info.plist
- How to set default application for specific file types in Mac OS X?
- Mac OS X file association works, but file icon not changed
As far as I read, these all work based on the Info.plist file in your
.app bundle.
plist example that I found in one of these topics:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
CFBundleDocumentTypes CFBundleTypeRole
Editor CFBundleTypeName
XYZ CFBundleTypeExtensions
xyz
CFBundleTypeIconFile XYZ
I have not yet tested this myself. This seems the correct way of doing
it.
Hope this helps ...
----------------------------------------------------------------------
Hansaplast · 2017-04-19 14:21
Sorry Phil - I guess we posted at almost the same time