Preferences
Register the native iOS preferences tool suite to read and mutate UserDefaults values under explicit store and key restrictions.
Install
Published pod: AnsightToolsPreferences.
SwiftPM:
.product(name: "AnsightToolsPreferences", package: "ansight-sdk")
CocoaPods:
pod 'AnsightToolsPreferences', '1.0.2-preview.1'
Register the Suite
import AnsightCore
import AnsightToolsPreferences
let preferences = AnsightPreferencesToolOptions(
defaultStore: "com.example.app",
allowedStores: ["com.example.app"],
allowedKeyPrefixes: ["debug."]
)
try AnsightRuntime.shared.registerPreferencesTools(options: preferences)
Registration API
registerPreferencesTools(options:): registers the suite.AnsightPreferencesToolOptions(defaultStore:allowedStores:allowedKeys:allowedKeyPrefixes:): configures store and key allow-lists.
Specific Concerns
- Preference values often include configuration or user state.
- Restrict stores, keys, or key prefixes at registration time.
prefs.set_valueis write-scoped.prefs.remove_keyis delete-scoped and requires.fullAccess.
Tool Matrix
| Name | Id | Scope | Description | Security |
|---|---|---|---|---|
List Preference Keys | prefs.list_keys | Read | Lists keys from a UserDefaults store. | Moderate |
Get Preference Value | prefs.get_value | Read | Reads one preference value. | High |
Set Preference Value | prefs.set_value | Write | Writes one preference value. | High |
Remove Preference Key | prefs.remove_key | Delete | Deletes one preference key. | High |
Tool Details
Use prefs.list_keys and prefs.get_value for inspection. Use prefs.set_value and prefs.remove_key only for local repair workflows where the allowed store and key policy is narrow.