Preferences
A tweak and its settings pane run in different processes. The pane runs in TweakInject; the tweak runs inside whatever it was injected into. They need to agree on a value without either being able to call the other, which is what this store is for.
Preferences live in plists under
/Library/TweakInject/Preferences/Defaults/, one file per domain.
The directory is group-writable by staff, so an injected tweak
running as the user can write to it without a privileged helper.
The first write creates the file, so your package does not need to ship one. Keep your defaults in your own code, or register them with PSUserDefaults, and the store holds only what someone has actually changed.
Which API to use
| API | Style | Use when |
|---|---|---|
| PSPreferences | C, CoreFoundation | You are writing C, or inside a constructor before Objective-C is convenient. |
| PSUserDefaults | Objective-C class | You want something shaped like NSUserDefaults, with typed accessors and registered defaults. |
| PSPreferenceController | Objective-C protocol | You are writing a custom settings pane rather than a declarative one. |
PSPreferences and PSUserDefaults read and write the same files. Mixing them within one tweak is fine.
Domains
A domain is normally your package identifier. Use the same string everywhere,
including in the defaults key of a preference bundle's
Info.plist, or the pane will write somewhere the tweak is not
reading.
Linking
Link /Library/TweakInject/TI_Support.dylib and build against
the TI_Support headers, which are
published with each TweakInject release.