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_value is write-scoped.
  • prefs.remove_key is delete-scoped and requires .fullAccess.

Tool Matrix

NameIdScopeDescriptionSecurity
List Preference Keysprefs.list_keysReadLists keys from a UserDefaults store.Moderate
Get Preference Valueprefs.get_valueReadReads one preference value.High
Set Preference Valueprefs.set_valueWriteWrites one preference value.High
Remove Preference Keyprefs.remove_keyDeleteDeletes 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.