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.
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. |
| PSPrefsCore | C functions, Foundation types | You need the whole domain at once, or the path to the file. |
| PSPreferenceController | Objective-C protocol | You are writing a custom settings pane rather than a declarative one. |
All four 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. Its install name is
absolute, so -L only matters at build time and the loader
resolves it at the recorded path.