Author: Marc Culler
State: Draft
Type: Project
Created: 2025-06-13
Tcl-Version: 9.1
Keywords: mac Info.plist
Abstract
This TIP proposes to add a new Tk command named ::tk::mac::GetInfoAsJSON. As with all commands in the ::tk::mac namespace, the new command would only be available in the Aqua version of Tk, which only runs on macOS.
Target
This TIP targets version 9.1 of Tk.
Rationale
When the Aqua Tk package is loaded, a macOS NSApplication is created and started. Every NSApplication includes a file named Info.plist which is read by the Apple launchd when the application is launched. The .plist format is an XML format which serializes a dictionary with string keys and values of basic types, including strings, numbers, arrays and dictionaries of the same type. There are some keys in the Info.plist which are required by launchd and many optional keys.
The Objective C Dictionary serialized by its Info.plist file is available for use by an NSApplication. It is provided as the infoDictionary property of the singleton NSBundle object named mainBundle. The purpose of the new command is to expose the same data at the Tcl level. For simplicity, the new command provides the infoDictionary in serialized form, as a JSON-encoded Tcl string. The string can be deserialized, for example by using the ::json::json2dict command provided by the json package in the Tcllib, to provide a Tcl dict. (This is simple because Apple provides a tool for serializing an Objective C Dictionary in JSON format.)
Access to the infoDictionary was requested as an informal RFE on the Tcl Core list by Iohannes Zmölnig. The intended purpose was to create template code for a Tk-based macOS app, which will need access to the display name of its NSApplication.
Specification
The command accepts no arguments or options. It returns a Tcl string which is the JSON encoding of a dictionary, as explained above.
Compatibility
There are no backwards incompatibilities created by adding this command.
Reference Implementation
The new command is implemented in the json_info_plist branch in the Tk fossil repository.
Example
The following Wish session shows the command in use:
% package require json
1.3.6
% set infodict [::json::json2dict [::tk::mac::GetInfoAsJSON]]; list
% dict get $infodict CFBundleName
Wish
% dict get $infodict CFBundleVersion
9.1a0
Copyright
This document has been placed in the public domain.