An information property list file is a structured text file that contains essential configuration information for a bundled executable. The file itself is typically encoded using the Unicode UTF-8 encoding and the contents are structured using XML. The root XML node is a dictionary, whose contents are a set of keys and values describing different aspects of the bundle. The system uses these keys and values to obtain information about your app and how it is configured. As a result, all bundled executables (plug-ins, frameworks, and apps) are expected to have an information property list file.

  1. Implementing Custom URL Schemes
  2. IDE
  3. See Full List On Docs.microsoft.com
  4. App Related Resources
  5. Find A .plist File For A Specific Application - Mac OS X Hints

question ipa.cpp:438 cannot find.app/info.plist. Posted by 3 years ago. Suggests Apple should allow sideloading apps via Mac or PC but not. Delete the app preference file. Plist files can become corrupt when a Mac shuts down or restarts unexpectedly or when an app freezes or crashes. As a result, the app may not open. When you delete a bad preference file, the Mac creates a new plist file that contains all the app's defaults automatically.

  1. The structure is the same for all Mac OS X applications. There is a Contents directory with an XML file named info.plist, a text file named PkgInfo, a MacOS directory, and a Resources directory. If you don't have a creator code registered with Apple the PkgInfo text file should contain only the following.
  2. Info.plist - The primary property list for Mac OS X applications, located in the /Contents/ directory of an.APP bundle. To view this file, right-click an application file, select 'Show Package Contents,' and open the Contents folder.
  3. Jun 04, 2018 The Info.plist File Configures Your App. Every app and plug-in uses an Info.plist file to store configuration data in a place where the system can easily access it. MacOS and iOS use Info.plist files to determine what icon to display for a bundle, what document types an app supports, and many other behaviors that have an impact outside the.

By convention, the name of an information property list file is Info.plist. This name of this file is case sensitive and must have an initial capital letter I. In iOS apps, this file resides in the top-level of the bundle directory. In macOS bundles, this file resides in the bundle’s Contents directory. Xcode typically creates this file for you automatically when you create a project of an appropriate type.

Important: In the sections that follow, pay attention to the capitalization of files and directories that reside inside a bundle. The NSBundle class and Core Foundation bundle functions consider case when searching for resources inside a bundle directory. Case mismatches could prevent you from finding your resources at runtime.

Creating and Editing an Information Property List File

The simplest way to create an information property list file is to let Xcode create it for you. Each new bundle-based project that you create in Xcode comes with a file named <project>-Info.plist, where <project> is the name of the project. At build time, this file is used to generate the Info.plist file that is then included in the resulting bundle.

To edit the contents of your information property list file, select the <project>-Info.plist file in your Xcode project to display the property list editor. Figure 1 shows the editor for the information property list file of a new Cocoa app project. The file created by Xcode comes preconfigured with keys that every information property list should have.

To edit the value for a specify key, double-click the value in the Xcode property list editor to select it, then type a new value. Most values are specified as strings but Xcode also supports several other scalar types. You can also specify complex types such as an array or dictionary. The property list editor displays an appropriate interface for editing each type. To change the type of a given value, make sure the value is not selected and Control-click it to display its contextual menu. From the Value Type submenu, select the type you want to use for the value.

Because information property lists are usually just text files, you can also edit them using any text editor that supports the UTF-8 file encoding. Because they are XML files, however, editing property list files manually is generally discouraged.

Adding Keys to an Information Property List File

Although the Info.plist file provided by Xcode contains the most critical keys required by the system, most apps should typically specify several additional keys. Many subsystems and system apps use the Info.plist file to gather information about your app. For example, when the user chooses File > Get Info for your app, the Finder displays information from many of these keys in the resulting information window.

You add keys to your app’s Info.plist using the Xcode property list editor. For information about how to use this editor, see “Edit property lists.”

Important: The property list editor in Xcode displays human-readable strings (instead of the actual key name) for many keys by default. To display the actual key names as they appear in the Info.plist file, Control-click any of the keys in the editor window and enable the Show Raw Keys/Values item in the contextual menu.

For a list of the recommended keys you should include in a typical app, see Recommended Info.plist Keys.

Localizing Property List Values

The values for many keys in an information property list file are human-readable strings that are displayed to the user by the Finder or your own app. When you localize your app, you should be sure to localize the values for these strings in addition to the rest of your app’s content.

Localized values are not stored in the Info.plist file itself. Instead, you store the values for a particular localization in a strings file with the name InfoPlist.strings. You place this file in the same language-specific project directory that you use to store other resources for the same localization. The contents of the InfoPlist.strings file are the individual keys you want localized and the appropriately translated value. The routines that look up key values in the Info.plist file take the user’s language preferences into account and return the localized version of the key (from the appropriate InfoPlist.strings file) when one exists. If a localized version of a key does not exist, the routines return the value stored in the Info.plist file.

For example, the TextEdit app has several keys that are displayed in the Finder and thus should be localized. Suppose your information property list file defines the following keys:

The French localization for TextEdit then includes the following strings in the InfoPlist.strings file of its Contents/Resources/French.lproj directory:

For more information about the placement of InfoPlist.strings files in your bundle, see Bundle Programming Guide. For information about creating strings files, see Resource Programming Guide. For additional information about the localization process, see Internationalization and Localization Guide.

Creating Platform- and Device-Specific Keys

You can designate a key in an Info.plist file as applying to a specific platform, a specific device type, or both. To create a platform- or device-specific key variant, combine a root key name with one or two qualifiers, using the following pattern:

key_root-<platform>~<device>

In this pattern, the key_root portion represents the original name of the key, as you find it in this document. The <platform> and <device> portions are optional and restrict the key’s applicability to a specific platform or device type. Notice that if you employ a platform qualifier, connect it with a hyphen (-), and if you employ a device qualifier, connect it with a tilde (~).

Use of a device qualifier is much more common than is use of a platform qualifier.

For a device qualifier, you can use one of the following values:

  • iphone The key applies to iPhone devices only

  • ipod The key applies to iPod touch devices only

  • ipad The key applies to iPad devices only

For a platform qualifier, you can specify a value of iphoneos or macos depending on which of these two platforms you are targeting.

When specifying a key variant, do so in addition to employing a corresponding key without any qualifiers, thereby ensuring you provide a reasonable default value. When the system searches for a key in your app’s Info.plist file, it chooses the key that is most specific to the current device and platform. If it does not find a qualified key, it looks for one without qualifiers. For example, to specify support for all device orientations on iPad, and three orientations for iPhone, the Xcode templates specify the corresponding keys in an app’s Info.plist file:

Custom Keys

iOS and macOS ignore custom keys you include in an Info.plist file. If you want to include app-specific configuration information in your Info.plist file, you can do so freely as long as your key names do not conflict with the ones Apple uses. When defining custom key names, prefix them with a unique prefix, such as your app’s bundle ID or your company’s domain name, to prevent conflicts.

Recommended Info.plist Keys

Each of the Xcode application templates includes an Info.plist file, but you can also construct one from scratch. When creating an information property list file, there are several keys you should always include. These keys are almost always accessed by the system and providing them ensures that the system has the information it needs to work with your app effectively.

Recommended Keys for iOS Apps

It is recommended that an iOS app include the following keys in its information property list file. Most are set by Xcode automatically when you create your project.

In addition to these keys, there are several that are commonly included:

  • UIRequiredDeviceCapabilities (required)

For descriptions of these keys, see the other chapters of this book.

Recommended Keys for Cocoa Apps

It is recommended that a Cocoa app include the following keys in its information property list file. Most are set by Xcode automatically when you create your project but some may need to be added.

These keys identify your app to the system and provide some basic information about the services it provides. Cocoa apps should also include the following keys to identify key resources in the bundle:

Note: If you are building a Cocoa app using an Xcode template, the NSMainNibFile and NSPrincipalClass keys are typically already set in the template project.

Mac App Info.plist

For descriptions of these keys, see the other chapters of this book.

Commonly Localized Keys

In addition to the recommended keys, there are several keys that should be localized and placed in your language-specific InfoPlist.strings files:

For more information about localizing information property list keys, see Localizing Property List Values.



Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use Privacy Policy Updated: 2018-06-04

Part 8: Making Your Lazarus App Mac-Friendly

Lazarus is a versatile and extensible tool, but its Delphi-influenced heritage does not match up well with the needs of Mac applications, particularly in the user interface department. And since you won't be using Apple's Xcode IDE at all when developing a Lazarus app on Mac, you'll need to do a number of things manually and outside of the Lazarus IDE.

If you simply recompile a Lazarus or converted Delphi app with Lazarus on Mac, you'll end up with a vaguely Win95 look and feel that would likely fall short of the user interface guidelines of Apple's new Mac App Store. However, with a few conditionally compiled code additions, you can get your app to act a lot more like a standard Mac app.

Here are some problem areas that this article attempts to address:

Note that this article assumes that you're compiling with the Carbon widgetset using Lazarus 0.9.29 or later. However, much of this article will also apply to any future Cocoa-based widgetset. Some parts should even be applicable to non-LCL Pascal Cocoa development.

Also, I've created several small convenience units and added them to the XDev Toolkit (a miscellaneous collection of stuff I've developed over the years). The CFHelpers unit has routines that make it easier to work with OS X Core Foundation (CF) strings in Pascal. The PropListUtil unit makes working with property list files easier and the PrefsUtil unit makes reading and writing application preferences easier. The XDev Toolkit is here:

Apple's Mac App Store guidelines are here (login required):

Application menu

All Mac apps have an 'application' menu between the Apple menu and the app's File menu on the menu bar at the top of the screen. The name of the app menu is the same as your app's name and is obtained from your app's bundle name (more below on that).

When you compile an app on Mac with Lazarus, you automatically get the app menu without doing anything yourself, but this default app menu lacks two menu items that typically appear in different menus on other platforms, namely the About and Preferences items. Fortunately it's easy to add these yourself conditionally.

Implementing Custom URL Schemes

First, you'll need to add something like this to your main form's declaration:

Now add this in the main form's FormCreate handler or some other startup code: Note that the app menu already has a Quit command, so you'll want to delete (conditionally) any Quit or Exit command from your File menu, as well as remove About and Preferences commands if they appear elsewhere in the main menu (in which case you can just reuse them here instead of creating them again).

Button size and position

In the physical world, push buttons are probably more likely these days to have a rounded shape than the rectangular shape of buttons on Windows (and by transference, Linux). Mac push buttons reflect this and have an oval shape. But with the Lazarus Carbon widgetset, if a button is greater than 22 pixels high (Height property), it's drawn as a rectangle, so make sure you limit button height in the Lazarus form designer to 22 or less (TButton, TBitBtn).

That works fine if you're targeting only Mac, but what if you have a cross-platform app and you're perfectly happy with the 'square' (old fashioned) look on Windows and Linux and want oval buttons only on Mac? Unfortunately, Lazarus form design files (.lfm), like Delphi's form design files (.dfm), don't support any kind of conditional property values. So what to do?

One solution would be to have two sets of form files, but this seems like overkill if all you want is oval buttons, although it does allow you then to modify anything else in the form (useful elsewhere as we'll see later).

Another approach is to use a utility like the XDev Toolkit's DfmToLfm converter to reduce button height automatically in form files that you're converting from Delphi.

A third possibility would be to reduce button height at runtime, using conditional code.

On a Mac dialog with a Cancel button, the Cancel button is positioned to the left of the 'action' button (OK, Save, etc.). This is opposite the usual way that buttons are positioned on Windows. Again, what to do?

If you don't want two sets of form files, you could do something like this to avoid sprinkling conditional code throughout your form Pascal files: Now each place where you invoke a dialog box, add a single line of code (which is basically a no-op on other platforms): While improper button position is one thing that will really flag your app as a port from an alien platform, there are other important button differences as well. For example, Mac buttons normally appear at the bottom right of the dialog. For more information, refer to Apple's Human Interface Guidelines (HIG):

Dialog boxes and modal sheets

Mac apps tend to use fewer modal dialogs than apps on Windows. For example, the About and Preferences dialogs in most Mac apps are modeless. They also lack an OK or Close or Cancel button, relying instead on the title bar's close button to dismiss the dialog. This means that changes in preferences that affect the app's look (for example, colors) tend to go into effect as soon as they're made, rather than after the dialog is closed.

When a Mac app does need a user response before it can proceed, it normally uses a modal 'sheet', not a modal dialog. A modal sheet does not block access to the rest of the application the way a modal dialog does. It also has a different look, 'descending' from the main window's title bar as though pulled down ('unfurl' is Apple's term), rather than popping up like a dialog. A sheet is 'document modal' rather than 'application modal'.

Unfortunately, sheets are an alien concept to Delphi VCL and thus Lazarus LCL, so you won't be able to use them in your Lazarus apps. And you will probably never be able to use them, even in a future Cocoa-based Lazarus, unless a sea change occurs in the LCL and support is added for sheets. If you're developing in Pascal with Cocoa but not using the LCL, then of course you can (and should) use sheets, but with the LCL this feature will probably remain out of reach. Part of the reason is that when a sheet is run, the app doesn't wait around until the sheet is closed the way it does when ShowModal is called. Instead, when the sheet ends, its delegate object is called and that object handles the sheet's results. This requires a different program structure than modal dialogs (calling code handles results) or modeless dialogs (dialog handles close event).

To display a dialog modelessly while retaining its modal behavior on Windows, you can do something conditionally like this:

Be sure to add an OnClose handler to your dialog like this:

Note this assumes you're using the global form variable that the Delphi and Lazarus form designers declare for you automatically. On Mac, we're also using that variable to determine whether it's okay to display the dialog since we don't want multiple instances of it.

What else can you do to make your forms look and act more like they do on a Mac? Well, you can make sure that tabbing between controls works correctly.

On a Mac, quite a few controls such as buttons, combo boxes and so on do not receive the keyboard focus. They can only be operated with the mouse. This interferes with normal VCL/LCL tab stops. In fact, it's impossible to tab past one of these controls unless you set the control's TabStop property to False. Again, if you're targeting only Mac, this is easy to do. But if your app targets Windows too, that just flips the tabbing problem back to Windows.

The XDev Toolkit's DfmToLfm converter handles this by inserting TabStop = False into the .lfm files it creates from Delphi .dfm files. You could do something similar. That is, you could have two sets of .lfm files. You only edit one set and auto-create the other using some kind of converter, which inserts the TabStop property. Then on Mac you would conditionally use the second set of forms.

Info.plist file and version info

OS X uses property list files (.plist extension) in a number of places. One of the first places you'll encounter a property list file is in your app bundle's Info.plist file.

A property list file is just an XML file of key-value pairs. You tell OS X about your app via the app's Info.plist file. You can also use it to store version information for your app.

Actually, there's already a number of keys in the Info.plist file that correspond to items in a version resource embedded in a Windows executable. For example, the Info.plist key CFBundleShortVersionString key is similar to FileVersion and the NSHumanReadableCopyright key can be used like LegalCopyright.

When you first compile a Lazarus app, you can let the IDE create the app bundle and its Info.plist file for you, but this is only the most rudimentary of Info.plist files. To edit and add to it, you can either use a text editor or you can double-click the Info.plist file and edit it in the OS X Property List Editor app.

You can also add your own custom keys, naming the key using your app's bundle identifier to ensure they're unique and won't collide with any future Apple keys. For example, your bundle identifier should be in this form:

Now just use it to prefix your own keys, like this to add CompanyName to your Info.plist file:

IDE

To retrieve version info (or anything else) from your app's Info.plist file at runtime (for use in an About box, for example), you can employ something like this little function from the PropListUtil unit:

You use the function like this in your program:

You can also use the PropListUtil unit's TCFPropertyList class to load an entire property list file.

For more information about Info.plist keys, refer to Apple's docs:

Preferences

Application preferences are stored in the ~/Library/Preferences folder. OS X automatically creates a preferences file for you when you run your app, naming it using your app's bundle identifier with the .plist extension.

Since preferences are stored in a property list file (key-value pairs), the preference values can be any of the property list object types (CFString, CFBoolean, CFNumber, CFDate, CFData, CFArray and CFDictionary). For example to write a string value to the preferences file, you could use the TCFPreferences class from the PrefsUtil unit:

Note the format of the key name. This is the way TextWrangler names its preference keys; it seems like a good approach.

To read a preference string value, you can use the same class:

For more information about preferences, refer to Apple's docs:

Mac App Info.plist

Double-clicking and dropping your app's files

The Lazarus wiki covers how to add an icon to your app bundle so the icon is displayed on the Dock for your app:

The next step is to associate that icon with file types that your app can open and also to associate those file types with your app. You do that by adding a section to your app bundle's Info.plist file that looks like this (for files with the .myext extension):

But this isn't really of much use if your app can't open a file that's been double-clicked. Typically on Windows you check ParamStr(1) at startup to see if a file name was passed to the app on the command line as a result of double clicking the file. But ParamStr doesn't work that way on OS X. Instead, you need to add a drop-file handler to your main form, as follows:

Then do this at startup, for example in your main form's FormCreate handler:

And implement the handler like this:

A few things worth noting:

  • OnDropFiles is a standard event property that can be set in the Lazarus form designer. However, you can also set it at runtime like this, for example if you want to conditionally restrict it and its handler to Mac.
  • This method also adds support for opening a file that's been dropped on your app on the Dock. If your app is not currently running, this also starts your app.
  • Since FileNames is an array, this means more than one file can be dropped and opened at the same time, for example if your app supports a multiple document interface.
  • If your app can only open one file at a time (single document interface), you'll probably want to check in the event handler if a file is already open and whether it needs to be saved first before the new file is opened.
For more information on the relevant Info.plist keys, consult Apple's docs.

Help

On the Mac, you can add simple help to your app without any programming. If your help is in a single HTML file, here's all you have to do:
  1. Create a help folder below your app bundle's Resources folder, for example named Help.
  2. Add this tag to the <head> section of your HTML file:
  3. Place your HTML file in the help folder.
  4. Add two keys to your app bundle's Info.plist file:
This automatically adds a Help menu with two items to your app's menu bar. The first item is the familiar Search command with its text box where you type in a help topic or keyword to search for. The second item is for your help file - when you choose it, your HTML file will be displayed in the OS X Help Viewer app.

To provide context sensitive help and also searchable topics and keywords, you use the OS X Help Indexer app:

  1. Create your help folder in a localized folder below Resources. For example, if your help is in English, the localized folder would be named English.lproj. That is, the path to your help folder would be myapp.app/Contents/Resources/English.lproj/Help (note you don't have to name it 'Help').
  2. Split up your HTML help into an index file and one file for each topic. The index file is the only one with the meta tag given above.
  3. Start Help Indexer and select your help folder. You can also drag and drop the folder to the Help Indexer on the Dock. Or you can use the command line utility, hiutil, as follows (change to your help folder in Terminal):
Now you can search keywords and HTML anchors (if you indexed them too) in Help Search. To display a topic from within your program when a help button is clicked, do this:
  1. Set the form's HelpType to htKeyword.
  2. Set the form's HelpKeyword to the anchor's name.
  3. Add a handler like this for the form's help button:

See Full List On Docs.microsoft.com

A few things worth noting:
  • Mac programs usually do not have context-sensitive help that's displayed when F1 or another key is pressed. Cmd+Shift+? is normally reserved to display the Help Search menu, not to display a help topic for the current context.
  • If your main menu already has a Help menu, you'll need to remove it so you don't have two Help menus:
  • While developing your help, you may find that the help system's caching is preventing you from seeing changes. If so, just delete these two folders from ~/Library/Caches:

    If order to empty the trash, you may need to shut down helpd (although it usually shuts down on its own in a few minutes). You can use the OS X Activity Monitor app to do this.

You can add video or just about anything you want to your help. For more information, consult Apple's docs: Copyright 2010 by Phil Hess.

Find A .plist File For A Specific Application - Mac OS X Hints

Last revised Nov 17, 2010.