├── .gitignore ├── Example └── Example │ ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved │ └── Example │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── ContentView.swift │ ├── ExampleApp.swift │ └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json ├── LICENSE ├── Package.resolved ├── Package.swift ├── README.md ├── Sources └── UserDefaultsEditor │ ├── PrivacyInfo.xcprivacy │ ├── UserDefaultsEditor.swift │ └── UserDefaultsType.swift └── Tests └── UserDefaultsEditorTests └── UserDefaultsEditorTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | xcuserdata/ 5 | DerivedData/ 6 | .swiftpm/configuration/registries.json 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | .netrc 9 | -------------------------------------------------------------------------------- /Example/Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 422F088E2B751FCD002D0B5E /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 422F088D2B751FCD002D0B5E /* ExampleApp.swift */; }; 11 | 422F08902B751FCD002D0B5E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 422F088F2B751FCD002D0B5E /* ContentView.swift */; }; 12 | 422F08922B751FCE002D0B5E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 422F08912B751FCE002D0B5E /* Assets.xcassets */; }; 13 | 422F08952B751FCE002D0B5E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 422F08942B751FCE002D0B5E /* Preview Assets.xcassets */; }; 14 | 422F089E2B751FF4002D0B5E /* UserDefaultsEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 422F089D2B751FF4002D0B5E /* UserDefaultsEditor */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 422F088A2B751FCD002D0B5E /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 422F088D2B751FCD002D0B5E /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = ""; }; 20 | 422F088F2B751FCD002D0B5E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | 422F08912B751FCE002D0B5E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 422F08942B751FCE002D0B5E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | 422F089B2B751FE7002D0B5E /* UserDefaultsEditor */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = UserDefaultsEditor; path = ../..; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | 422F08872B751FCC002D0B5E /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | 422F089E2B751FF4002D0B5E /* UserDefaultsEditor in Frameworks */, 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 422F08812B751FCC002D0B5E = { 39 | isa = PBXGroup; 40 | children = ( 41 | 422F089B2B751FE7002D0B5E /* UserDefaultsEditor */, 42 | 422F088C2B751FCD002D0B5E /* Example */, 43 | 422F088B2B751FCD002D0B5E /* Products */, 44 | 422F089C2B751FF4002D0B5E /* Frameworks */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 422F088B2B751FCD002D0B5E /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 422F088A2B751FCD002D0B5E /* Example.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 422F088C2B751FCD002D0B5E /* Example */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 422F088D2B751FCD002D0B5E /* ExampleApp.swift */, 60 | 422F088F2B751FCD002D0B5E /* ContentView.swift */, 61 | 422F08912B751FCE002D0B5E /* Assets.xcassets */, 62 | 422F08932B751FCE002D0B5E /* Preview Content */, 63 | ); 64 | path = Example; 65 | sourceTree = ""; 66 | }; 67 | 422F08932B751FCE002D0B5E /* Preview Content */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 422F08942B751FCE002D0B5E /* Preview Assets.xcassets */, 71 | ); 72 | path = "Preview Content"; 73 | sourceTree = ""; 74 | }; 75 | 422F089C2B751FF4002D0B5E /* Frameworks */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 422F08892B751FCC002D0B5E /* Example */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 422F08982B751FCE002D0B5E /* Build configuration list for PBXNativeTarget "Example" */; 88 | buildPhases = ( 89 | 422F08862B751FCC002D0B5E /* Sources */, 90 | 422F08872B751FCC002D0B5E /* Frameworks */, 91 | 422F08882B751FCC002D0B5E /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = Example; 98 | packageProductDependencies = ( 99 | 422F089D2B751FF4002D0B5E /* UserDefaultsEditor */, 100 | ); 101 | productName = Example; 102 | productReference = 422F088A2B751FCD002D0B5E /* Example.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | 422F08822B751FCC002D0B5E /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | BuildIndependentTargetsInParallel = 1; 112 | LastSwiftUpdateCheck = 1520; 113 | LastUpgradeCheck = 1520; 114 | TargetAttributes = { 115 | 422F08892B751FCC002D0B5E = { 116 | CreatedOnToolsVersion = 15.2; 117 | }; 118 | }; 119 | }; 120 | buildConfigurationList = 422F08852B751FCC002D0B5E /* Build configuration list for PBXProject "Example" */; 121 | compatibilityVersion = "Xcode 14.0"; 122 | developmentRegion = en; 123 | hasScannedForEncodings = 0; 124 | knownRegions = ( 125 | en, 126 | Base, 127 | ); 128 | mainGroup = 422F08812B751FCC002D0B5E; 129 | productRefGroup = 422F088B2B751FCD002D0B5E /* Products */; 130 | projectDirPath = ""; 131 | projectRoot = ""; 132 | targets = ( 133 | 422F08892B751FCC002D0B5E /* Example */, 134 | ); 135 | }; 136 | /* End PBXProject section */ 137 | 138 | /* Begin PBXResourcesBuildPhase section */ 139 | 422F08882B751FCC002D0B5E /* Resources */ = { 140 | isa = PBXResourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 422F08952B751FCE002D0B5E /* Preview Assets.xcassets in Resources */, 144 | 422F08922B751FCE002D0B5E /* Assets.xcassets in Resources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXResourcesBuildPhase section */ 149 | 150 | /* Begin PBXSourcesBuildPhase section */ 151 | 422F08862B751FCC002D0B5E /* Sources */ = { 152 | isa = PBXSourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | 422F08902B751FCD002D0B5E /* ContentView.swift in Sources */, 156 | 422F088E2B751FCD002D0B5E /* ExampleApp.swift in Sources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXSourcesBuildPhase section */ 161 | 162 | /* Begin XCBuildConfiguration section */ 163 | 422F08962B751FCE002D0B5E /* Debug */ = { 164 | isa = XCBuildConfiguration; 165 | buildSettings = { 166 | ALWAYS_SEARCH_USER_PATHS = NO; 167 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 168 | CLANG_ANALYZER_NONNULL = YES; 169 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 171 | CLANG_ENABLE_MODULES = YES; 172 | CLANG_ENABLE_OBJC_ARC = YES; 173 | CLANG_ENABLE_OBJC_WEAK = YES; 174 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 175 | CLANG_WARN_BOOL_CONVERSION = YES; 176 | CLANG_WARN_COMMA = YES; 177 | CLANG_WARN_CONSTANT_CONVERSION = YES; 178 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 181 | CLANG_WARN_EMPTY_BODY = YES; 182 | CLANG_WARN_ENUM_CONVERSION = YES; 183 | CLANG_WARN_INFINITE_RECURSION = YES; 184 | CLANG_WARN_INT_CONVERSION = YES; 185 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 186 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 187 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 188 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 189 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 190 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 191 | CLANG_WARN_STRICT_PROTOTYPES = YES; 192 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 193 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 194 | CLANG_WARN_UNREACHABLE_CODE = YES; 195 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 196 | COPY_PHASE_STRIP = NO; 197 | DEBUG_INFORMATION_FORMAT = dwarf; 198 | ENABLE_STRICT_OBJC_MSGSEND = YES; 199 | ENABLE_TESTABILITY = YES; 200 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 201 | GCC_C_LANGUAGE_STANDARD = gnu17; 202 | GCC_DYNAMIC_NO_PIC = NO; 203 | GCC_NO_COMMON_BLOCKS = YES; 204 | GCC_OPTIMIZATION_LEVEL = 0; 205 | GCC_PREPROCESSOR_DEFINITIONS = ( 206 | "DEBUG=1", 207 | "$(inherited)", 208 | ); 209 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 210 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 211 | GCC_WARN_UNDECLARED_SELECTOR = YES; 212 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 213 | GCC_WARN_UNUSED_FUNCTION = YES; 214 | GCC_WARN_UNUSED_VARIABLE = YES; 215 | IPHONEOS_DEPLOYMENT_TARGET = 17.2; 216 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 217 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 218 | MTL_FAST_MATH = YES; 219 | ONLY_ACTIVE_ARCH = YES; 220 | SDKROOT = iphoneos; 221 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; 222 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 223 | }; 224 | name = Debug; 225 | }; 226 | 422F08972B751FCE002D0B5E /* Release */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 234 | CLANG_ENABLE_MODULES = YES; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_ENABLE_OBJC_WEAK = YES; 237 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 238 | CLANG_WARN_BOOL_CONVERSION = YES; 239 | CLANG_WARN_COMMA = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 242 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 243 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INFINITE_RECURSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 250 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 251 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 252 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 253 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 254 | CLANG_WARN_STRICT_PROTOTYPES = YES; 255 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 256 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 264 | GCC_C_LANGUAGE_STANDARD = gnu17; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 267 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 268 | GCC_WARN_UNDECLARED_SELECTOR = YES; 269 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 270 | GCC_WARN_UNUSED_FUNCTION = YES; 271 | GCC_WARN_UNUSED_VARIABLE = YES; 272 | IPHONEOS_DEPLOYMENT_TARGET = 17.2; 273 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 274 | MTL_ENABLE_DEBUG_INFO = NO; 275 | MTL_FAST_MATH = YES; 276 | SDKROOT = iphoneos; 277 | SWIFT_COMPILATION_MODE = wholemodule; 278 | VALIDATE_PRODUCT = YES; 279 | }; 280 | name = Release; 281 | }; 282 | 422F08992B751FCE002D0B5E /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 286 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 287 | CODE_SIGN_STYLE = Automatic; 288 | CURRENT_PROJECT_VERSION = 1; 289 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 290 | DEVELOPMENT_TEAM = G8RH83B4LT; 291 | ENABLE_PREVIEWS = YES; 292 | GENERATE_INFOPLIST_FILE = YES; 293 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 294 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 295 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 296 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 297 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 298 | LD_RUNPATH_SEARCH_PATHS = ( 299 | "$(inherited)", 300 | "@executable_path/Frameworks", 301 | ); 302 | MARKETING_VERSION = 1.0; 303 | PRODUCT_BUNDLE_IDENTIFIER = com.ryu.Example; 304 | PRODUCT_NAME = "$(TARGET_NAME)"; 305 | SWIFT_EMIT_LOC_STRINGS = YES; 306 | SWIFT_VERSION = 5.0; 307 | TARGETED_DEVICE_FAMILY = "1,2"; 308 | }; 309 | name = Debug; 310 | }; 311 | 422F089A2B751FCE002D0B5E /* Release */ = { 312 | isa = XCBuildConfiguration; 313 | buildSettings = { 314 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 315 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 316 | CODE_SIGN_STYLE = Automatic; 317 | CURRENT_PROJECT_VERSION = 1; 318 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 319 | DEVELOPMENT_TEAM = G8RH83B4LT; 320 | ENABLE_PREVIEWS = YES; 321 | GENERATE_INFOPLIST_FILE = YES; 322 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 323 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 324 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 325 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 326 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 327 | LD_RUNPATH_SEARCH_PATHS = ( 328 | "$(inherited)", 329 | "@executable_path/Frameworks", 330 | ); 331 | MARKETING_VERSION = 1.0; 332 | PRODUCT_BUNDLE_IDENTIFIER = com.ryu.Example; 333 | PRODUCT_NAME = "$(TARGET_NAME)"; 334 | SWIFT_EMIT_LOC_STRINGS = YES; 335 | SWIFT_VERSION = 5.0; 336 | TARGETED_DEVICE_FAMILY = "1,2"; 337 | }; 338 | name = Release; 339 | }; 340 | /* End XCBuildConfiguration section */ 341 | 342 | /* Begin XCConfigurationList section */ 343 | 422F08852B751FCC002D0B5E /* Build configuration list for PBXProject "Example" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | 422F08962B751FCE002D0B5E /* Debug */, 347 | 422F08972B751FCE002D0B5E /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | 422F08982B751FCE002D0B5E /* Build configuration list for PBXNativeTarget "Example" */ = { 353 | isa = XCConfigurationList; 354 | buildConfigurations = ( 355 | 422F08992B751FCE002D0B5E /* Debug */, 356 | 422F089A2B751FCE002D0B5E /* Release */, 357 | ); 358 | defaultConfigurationIsVisible = 0; 359 | defaultConfigurationName = Release; 360 | }; 361 | /* End XCConfigurationList section */ 362 | 363 | /* Begin XCSwiftPackageProductDependency section */ 364 | 422F089D2B751FF4002D0B5E /* UserDefaultsEditor */ = { 365 | isa = XCSwiftPackageProductDependency; 366 | productName = UserDefaultsEditor; 367 | }; 368 | /* End XCSwiftPackageProductDependency section */ 369 | }; 370 | rootObject = 422F08822B751FCC002D0B5E /* Project object */; 371 | } 372 | -------------------------------------------------------------------------------- /Example/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "editvalueview", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/p-x9/EditValueView.git", 7 | "state" : { 8 | "revision" : "454d77987aea7a3673dc2b7ce8ab15efa154987f", 9 | "version" : "0.7.0" 10 | } 11 | }, 12 | { 13 | "identity" : "swift-magic-mirror", 14 | "kind" : "remoteSourceControl", 15 | "location" : "https://github.com/p-x9/swift-magic-mirror.git", 16 | "state" : { 17 | "revision" : "390e248dd6727e17aeb3949c12bb83e6eac876d1", 18 | "version" : "0.2.0" 19 | } 20 | }, 21 | { 22 | "identity" : "swiftui-reflection-view", 23 | "kind" : "remoteSourceControl", 24 | "location" : "https://github.com/p-x9/swiftui-reflection-view.git", 25 | "state" : { 26 | "revision" : "d4cef50ab1a3ea729df02807ad1c1698a5d646da", 27 | "version" : "0.8.1" 28 | } 29 | }, 30 | { 31 | "identity" : "swiftuicolor", 32 | "kind" : "remoteSourceControl", 33 | "location" : "https://github.com/p-x9/SwiftUIColor.git", 34 | "state" : { 35 | "revision" : "aa42f452698cc0f78dcba2c6544f4abf7724602f", 36 | "version" : "0.4.0" 37 | } 38 | } 39 | ], 40 | "version" : 2 41 | } 42 | -------------------------------------------------------------------------------- /Example/Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Example/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | } 8 | ], 9 | "info" : { 10 | "author" : "xcode", 11 | "version" : 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Example/Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Example/Example/ContentView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import UserDefaultsEditor 3 | 4 | struct ContentView: View { 5 | var body: some View { 6 | NavigationView { 7 | List { 8 | Section { 9 | NavigationLink("UserDefaultsEditor") { 10 | UserDefaultsEditor( 11 | userDefaults: .standard, 12 | presentationStyle: .push 13 | ) 14 | } 15 | } 16 | Section { 17 | Button("Add Integer Value") { 18 | UserDefaults.standard.set(1, forKey: "integerKey") 19 | } 20 | Button("Add String Value") { 21 | UserDefaults.standard.set("string", forKey: "stringKey") 22 | } 23 | Button("Add Data Value") { 24 | UserDefaults.standard.set("[{ \"string\": \"string\", \"integer\": 1 }]".data(using: .utf8), forKey: "dataKey") 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | 32 | #Preview { 33 | ContentView() 34 | } 35 | -------------------------------------------------------------------------------- /Example/Example/Example/ExampleApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @main 4 | struct ExampleApp: App { 5 | var body: some Scene { 6 | WindowGroup { 7 | ContentView() 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Example/Example/Example/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Ryu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "editvalueview", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/p-x9/EditValueView.git", 7 | "state" : { 8 | "revision" : "bb2ce6255b282542031f41ddaf597b37fb15b19c", 9 | "version" : "0.6.0" 10 | } 11 | }, 12 | { 13 | "identity" : "swift-magic-mirror", 14 | "kind" : "remoteSourceControl", 15 | "location" : "https://github.com/p-x9/swift-magic-mirror.git", 16 | "state" : { 17 | "revision" : "390e248dd6727e17aeb3949c12bb83e6eac876d1", 18 | "version" : "0.2.0" 19 | } 20 | }, 21 | { 22 | "identity" : "swiftuicolor", 23 | "kind" : "remoteSourceControl", 24 | "location" : "https://github.com/p-x9/SwiftUIColor.git", 25 | "state" : { 26 | "revision" : "aa42f452698cc0f78dcba2c6544f4abf7724602f", 27 | "version" : "0.4.0" 28 | } 29 | } 30 | ], 31 | "version" : 2 32 | } 33 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.9 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "UserDefaultsEditor", 8 | platforms: [ 9 | .iOS(.v15), 10 | .macOS(.v12) 11 | ], 12 | products: [ 13 | // Products define the executables and libraries a package produces, making them visible to other packages. 14 | .library( 15 | name: "UserDefaultsEditor", 16 | targets: ["UserDefaultsEditor"] 17 | ), 18 | ], 19 | dependencies: [ 20 | .package(url: "https://github.com/p-x9/EditValueView.git", from: "0.6.0") 21 | ], 22 | targets: [ 23 | // Targets are the basic building blocks of a package, defining a module or a test suite. 24 | // Targets can depend on other targets in this package and products from dependencies. 25 | .target( 26 | name: "UserDefaultsEditor", 27 | dependencies: [ 28 | .product(name: "EditValueView", package: "EditValueView") 29 | ], 30 | resources: [.copy("PrivacyInfo.xcprivacy")] 31 | ), 32 | .testTarget( 33 | name: "UserDefaultsEditorTests", 34 | dependencies: ["UserDefaultsEditor"] 35 | ), 36 | ] 37 | ) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UserDefaultsEditor 2 | A SwiftUI View for Easily Modifying UserDefaults Values for Debugging. 3 | 4 | | UserDefaultsEditor | Edit Date | Edit Array | 5 | | ---- | ---- | ---- | 6 | | | | | 7 | 8 | UserDefaultsEditor uses the [EditValueView](https://github.com/p-x9/EditValueView) for its value modification views. For more information about EditValueView, please visit their GitHub repository. 9 | 10 | # Usage 11 | For displaying the view with a push transition, please set presentationStyle to .push. For modal presentation, select .modal. 12 | 13 | ```Swift 14 | UserDefaultsEditor( 15 | userDefaults: .standard, 16 | presentationStyle: .push // or .modal 17 | ) 18 | ``` 19 | -------------------------------------------------------------------------------- /Sources/UserDefaultsEditor/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrivacyTracking 6 | 7 | NSPrivacyTrackingDomains 8 | 9 | NSPrivacyCollectedDataTypes 10 | 11 | NSPrivacyAccessedAPITypes 12 | 13 | 14 | NSPrivacyAccessedAPIType 15 | NSPrivacyAccessedAPICategoryUserDefaults 16 | NSPrivacyAccessedAPITypeReasons 17 | 18 | C56D.1 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Sources/UserDefaultsEditor/UserDefaultsEditor.swift: -------------------------------------------------------------------------------- 1 | import EditValueView 2 | import SwiftUI 3 | 4 | /// `UserDefaultsEditor` provides a SwiftUI view for modifying UserDefaults values. It leverages EditValueView for the individual value modification views, offering a user-friendly interface for debugging and editing UserDefaults entries directly within your app. This view supports both push and modal presentation styles. 5 | public struct UserDefaultsEditor: View { 6 | /// Defines the presentation style of the UserDefaults editor view. 7 | public enum PresentationStyle { 8 | case push // Presents the editor in a push navigation style. 9 | case modal // Presents the editor modally. 10 | } 11 | 12 | @State var presentedValue: UserDefaultsRepresentation? 13 | @State var allValues: [UserDefaultsRepresentation] 14 | @State var searchQuery: String = "" 15 | 16 | var filteredValues: [UserDefaultsRepresentation] { 17 | if searchQuery.isEmpty { 18 | allValues 19 | } else { 20 | allValues.filter { 21 | $0.key.lowercased().range(of: searchQuery.lowercased()) != nil 22 | } 23 | } 24 | } 25 | 26 | let presentationStyle: PresentationStyle 27 | let dataSource: () -> [String: Any] 28 | let write: (_ key: String, _ newValue: Any) -> Void 29 | let remove: (_ key: String) -> Void 30 | 31 | /// Initializes a `UserDefaultsEditor` view with the specified presentation style and UserDefaults source. 32 | /// - Parameters: 33 | /// - userDefaults: The UserDefaults instance to edit. 34 | /// - presentationStyle: The presentation style for the editor (default is `.push`). 35 | public init( 36 | userDefaults: UserDefaults, 37 | presentationStyle: PresentationStyle = .push 38 | ) { 39 | self.init( 40 | presentationStyle: presentationStyle, 41 | dictionary: userDefaults.dictionaryRepresentation(), 42 | write: { userDefaults.set($1, forKey: $0) }, 43 | remove: { userDefaults.removeObject(forKey: $0) } 44 | ) 45 | } 46 | 47 | fileprivate init( 48 | presentationStyle: PresentationStyle, 49 | dictionary: @escaping @autoclosure () -> [String: Any], 50 | write: @escaping (_ key: String, _ newValue: Any) -> Void, 51 | remove: @escaping (_ key: String) -> Void 52 | ) { 53 | let allValues = dictionary().userDefaultsRepresentations() 54 | self._allValues = .init(initialValue: allValues) 55 | self.write = write 56 | self.presentationStyle = presentationStyle 57 | self.remove = remove 58 | self.dataSource = dictionary 59 | } 60 | 61 | public var body: some View { 62 | switch presentationStyle { 63 | case .push: 64 | core 65 | case .modal: 66 | NavigationView { 67 | core 68 | } 69 | } 70 | } 71 | 72 | private var core: some View { 73 | List { 74 | ForEach(filteredValues) { data in 75 | HStack { 76 | Text(data.key) 77 | Spacer() 78 | Text(data.type.description) 79 | .foregroundColor(.blue) 80 | } 81 | .contentShape(Rectangle()) 82 | .onTapGesture { 83 | presentedValue = data 84 | } 85 | } 86 | .onDelete { indexSet in 87 | indexSet.forEach { remove(allValues[$0].key) } 88 | update() 89 | } 90 | } 91 | .refreshable { 92 | update() 93 | } 94 | .onAppear { 95 | update() 96 | } 97 | .sheet(item: $presentedValue) { value in 98 | switch value.type { 99 | case .string(let string): 100 | EditValueView(key: value.key, value: string) 101 | .onUpdate { newValue in 102 | write(value.key, newValue) 103 | update() 104 | } 105 | case .array(let array): 106 | EditValueView(key: value.key, value: array) 107 | .onUpdate { newValue in 108 | write(value.key, newValue) 109 | update() 110 | } 111 | case .dictionary(let dictionary): 112 | EditValueView(key: value.key, value: dictionary) 113 | .onUpdate { newValue in 114 | write(value.key, newValue) 115 | update() 116 | } 117 | case .data(let data): 118 | if let json = try? JSONSerialization.jsonObject(with: data) { 119 | EditValueView(key: value.key, value: json) 120 | .onUpdate { newValue in 121 | guard let data = try? JSONSerialization.data(withJSONObject: newValue) else { 122 | return 123 | } 124 | 125 | write(value.key, data) 126 | } 127 | } else { 128 | EditValueView(key: value.key, value: data) 129 | .onUpdate { newValue in 130 | write(value.key, newValue) 131 | update() 132 | } 133 | } 134 | 135 | case .stringArray(let array): 136 | EditValueView(key: value.key, value: array) 137 | .onUpdate { newValue in 138 | write(value.key, newValue) 139 | update() 140 | } 141 | case .integer(let int): 142 | EditValueView(key: value.key, value: int) 143 | .onUpdate { newValue in 144 | write(value.key, newValue) 145 | update() 146 | } 147 | case .float(let float): 148 | EditValueView(key: value.key, value: float) 149 | .onUpdate { newValue in 150 | write(value.key, newValue) 151 | update() 152 | } 153 | case .double(let double): 154 | EditValueView(key: value.key, value: double) 155 | .onUpdate { newValue in 156 | write(value.key, newValue) 157 | update() 158 | } 159 | case .bool(let bool): 160 | EditValueView(key: value.key, value: bool) 161 | .onUpdate { newValue in 162 | write(value.key, newValue) 163 | update() 164 | } 165 | case .url(let url): 166 | EditValueView(key: value.key, value: url) 167 | .onUpdate { newValue in 168 | write(value.key, newValue) 169 | update() 170 | } 171 | case .date(let date): 172 | EditValueView(key: value.key, value: date) 173 | .onUpdate { newValue in 174 | write(value.key, newValue) 175 | update() 176 | } 177 | case .object(let any): 178 | EditValueView(key: value.key, value: any) 179 | .onUpdate { newValue in 180 | write(value.key, newValue) 181 | update() 182 | } 183 | } 184 | } 185 | .searchable(text: $searchQuery) 186 | } 187 | 188 | func update() { 189 | allValues = dataSource().userDefaultsRepresentations() 190 | } 191 | } 192 | 193 | extension [String: Any] { 194 | func userDefaultsRepresentations() -> [UserDefaultsRepresentation] { 195 | self 196 | .sorted(by: { $0.key < $1.key }) 197 | .reduce(into: [UserDefaultsRepresentation]()) { partialResult, element in 198 | partialResult.append( 199 | UserDefaultsRepresentation( 200 | key: element.key, 201 | type: UserDefaultsType.identify(element.value) 202 | ) 203 | ) 204 | } 205 | } 206 | } 207 | 208 | #Preview { 209 | UserDefaultsEditor( 210 | presentationStyle: .modal, 211 | dictionary: [ 212 | "string": "hoge", 213 | "array": [1, "2", 3], 214 | "dictionary": ["a": 0], 215 | "data": "[{ \"string\": \"string\", \"integer\": 1 }]".data(using: .utf8)!, 216 | "stringArray": ["a", "b"], 217 | "integer": 1, 218 | "float": Float(1), 219 | "double": Double(1), 220 | "bool": false, 221 | "url": URL(string: "https://google.com")!, 222 | "date": Date() 223 | ], 224 | write: { _, _ in }, 225 | remove: { _ in } 226 | ) 227 | } 228 | -------------------------------------------------------------------------------- /Sources/UserDefaultsEditor/UserDefaultsType.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import EditValueView 3 | import SwiftUI 4 | 5 | enum UserDefaultsType { 6 | case string(String) 7 | case array([Any]) 8 | case dictionary([String: Any]) 9 | case data(Data) 10 | case stringArray([String]) 11 | case integer(Int) 12 | case float(Float) 13 | case double(Double) 14 | case bool(Bool) 15 | case url(URL) 16 | case date(Date) 17 | case object(Any) 18 | 19 | var description: String { 20 | switch self { 21 | case .string(let string): 22 | string.description 23 | case .array(let array): 24 | array.description 25 | case .dictionary(let dictionary): 26 | dictionary.description 27 | case .data(let data): 28 | if let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []), 29 | let jsonData = try? JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted, .sortedKeys]), 30 | let jsonString = String(data: jsonData, encoding: .utf8) 31 | { 32 | jsonString 33 | } else if let string = String(data: data, encoding: .utf8) { 34 | string 35 | } else { 36 | data.description 37 | } 38 | case .stringArray(let array): 39 | array.description 40 | case .integer(let int): 41 | int.description 42 | case .float(let float): 43 | float.description 44 | case .double(let double): 45 | double.description 46 | case .bool(let bool): 47 | bool.description 48 | case .url(let url): 49 | url.description 50 | case .date(let date): 51 | date.description 52 | case .object(let any): 53 | String(reflecting: any) 54 | } 55 | } 56 | 57 | static func identify(_ value: Any) -> Self { 58 | switch value { 59 | case let string as String: 60 | return .string(string) 61 | case let stringArray as [String]: 62 | return .stringArray(stringArray) 63 | case let array as [Any]: 64 | return .array(array) 65 | case let dictionary as [String: Any]: 66 | return .dictionary(dictionary) 67 | case let data as Data: 68 | return .data(data) 69 | case let integer as Int: 70 | return .integer(integer) 71 | case let float as Float: 72 | return .float(float) 73 | case let double as Double: 74 | return .double(double) 75 | case let bool as Bool: 76 | return .bool(bool) 77 | case let url as URL: 78 | return .url(url) 79 | case let date as Date: 80 | return .date(date) 81 | default: 82 | return .object(value) 83 | } 84 | } 85 | } 86 | 87 | struct UserDefaultsRepresentation: Identifiable { 88 | var id: String { 89 | key 90 | } 91 | let key: String 92 | let type: UserDefaultsType 93 | } 94 | -------------------------------------------------------------------------------- /Tests/UserDefaultsEditorTests/UserDefaultsEditorTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import UserDefaultsEditor 3 | 4 | final class UserDefaultsEditorTests: XCTestCase { 5 | func testExample() throws { 6 | // XCTest Documentation 7 | // https://developer.apple.com/documentation/xctest 8 | 9 | // Defining Test Cases and Test Methods 10 | // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods 11 | } 12 | } 13 | --------------------------------------------------------------------------------