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.4.0-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_value uses .write.
  • prefs.remove_key uses .critical and requires .fullAccess.

Tool Matrix

NameIdPolicyDescription
List Preference Keysprefs.list_keysReadLists keys from a UserDefaults store.
Get Preference Valueprefs.get_valueReadReads one preference value.
Set Preference Valueprefs.set_valueWriteWrites one preference value.
Remove Preference Keyprefs.remove_keyCriticalDeletes one preference key.

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.