Dev:PreferenceLoader

PreferenceLoader is an open-source MobileSubstrate based utility that allows developers to add entries to the Settings application, similar to the Settings bundles that AppStore apps use.

The approach PreferenceLoader takes is different from other approaches in that the Settings-iPhone.plist and Settings-iPod.plist files are not modified on disk. When the Settings application is loaded, entries are read from plists in /Library/PreferenceLoader/Preferences/ and are dynamically added to the list before the AppStore applications' preferences group.

PreferenceLoader also allows PreferenceBundles to be loaded from /Library/PreferenceBundles/.

Entry file
Each entry is defined in its own plist. There are at least three ways to approach preferences support for your tweaks.

Reduced approach
Provides a switch on the root section of the preferences (like Airplane Mode). Recommended for configuration-less tweaks.

This sets up an entry called  with an icon loaded from   to the left and a UISwitch on the right, starting in the ON position, saving the value in   for the key enabled and posting a Darwin notification named.

Simple Approach
Provides a pane where other cells can appear (like Wi-Fi). Recommended for configuration-friendly tweaks. Here's an example:

This sets up an entry called  with an icon loaded from   to the left. The pushed page has the title set to Test Settings. The page will only contain a cell with the label Enabled UISwitch on the right, starting in the ON position, saving the value in  for the key enabled and posting a Darwin notification named.

For more preferences values you can add specifier dictionaries to the items array.

There is a good tutorial on how to create settings plists on MMi.

PreferenceBundle Approach
You can create custom settings pages that are able to execute code. This only requires a plist that loads a PreferenceBundle. Here's an example:

This sets up an entry called  with an icon loaded from   to the left. The rest of the details are up to the bundle named TestSettings.

Filtering
In a way similar to that of MobileSubstrate, PreferenceLoader supports filters for entry plists and specifiers. The filter should be a dictionary for the key pl_filter</tt> which can contain these keys:


 * CoreFoundationVersion (array): The entry or specifier is loaded or displayed only if the version of CoreFoundation.framework is above the specified value or within the specified range. Currently, only the first 2 values are checked.

Below sample specifier will filter for iOS 6.0 or later.

Localization
Preferences.framework can localize strings in specifier properties, such as titles and labels.

Place your specifier plists and icons in a folder within /Library/PreferenceLoader/Preferences/</tt>. For each file</tt>.plist file and for each language you have translations for, create a file</tt>.strings.

Example code
https://github.com/Sassoty/theos-examples/tree/master/preferenceloader