├── .DS_Store ├── .gitignore ├── GenericLocalPersistence.podspec ├── GenericLocalPersistence.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── GenericLocalPersistence ├── GenericLocalPersistence.h ├── Info.plist ├── Managers │ ├── DefaultManager.swift │ ├── KeyChainManager.swift │ └── PlistManager.swift └── extension │ └── Encodable.swift ├── LICENSE └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/GenericLocalPersistence/847dd0ae83bbd702a88d4bb5c69f727e12fe412b/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /GenericLocalPersistence.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | 3 | spec.name = "GenericLocalPersistence" 4 | spec.version = "0.0.1" 5 | spec.summary = "A cocoaPod library written in swift." 6 | spec.description = "A cocoaPod library written in swift for local Persistence." 7 | 8 | spec.platform = :ios, "12.1" 9 | 10 | spec.homepage = "https://github.com/Riddhi-mi/GenericLocalPersistence" 11 | spec.license = { :type => "MIT", :file => "LICENSE" } 12 | spec.author = { "RiddhiPatel" => "riddhi.patel@mindinventory.com" } 13 | spec.source = { :git => "https://github.com/Riddhi-mi/GenericLocalPersistence.git", :tag => "#{spec.version}"} 14 | spec.source_files = "GenericLocalPersistence/**/*.{h,m,swift}" 15 | spec.exclude_files = "Classes/Exclude" 16 | spec.swift_version = "4.2" 17 | end 18 | -------------------------------------------------------------------------------- /GenericLocalPersistence.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8115D01E265D057700CBC6FC /* GenericLocalPersistence.h in Headers */ = {isa = PBXBuildFile; fileRef = 8115D01C265D057700CBC6FC /* GenericLocalPersistence.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 8115D027265D059B00CBC6FC /* Encodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8115D026265D059B00CBC6FC /* Encodable.swift */; }; 12 | 8115D02B265D05D400CBC6FC /* DefaultManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8115D02A265D05D400CBC6FC /* DefaultManager.swift */; }; 13 | 8115D02F265D05F600CBC6FC /* KeyChainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8115D02E265D05F600CBC6FC /* KeyChainManager.swift */; }; 14 | 8115D032265D060F00CBC6FC /* PlistManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8115D031265D060F00CBC6FC /* PlistManager.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 8115D019265D057700CBC6FC /* GenericLocalPersistence.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GenericLocalPersistence.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 8115D01C265D057700CBC6FC /* GenericLocalPersistence.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GenericLocalPersistence.h; sourceTree = ""; }; 20 | 8115D01D265D057700CBC6FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 21 | 8115D026265D059B00CBC6FC /* Encodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encodable.swift; sourceTree = ""; }; 22 | 8115D02A265D05D400CBC6FC /* DefaultManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultManager.swift; sourceTree = ""; }; 23 | 8115D02E265D05F600CBC6FC /* KeyChainManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChainManager.swift; sourceTree = ""; }; 24 | 8115D031265D060F00CBC6FC /* PlistManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlistManager.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 8115D016265D057700CBC6FC /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 8115D00F265D057700CBC6FC = { 39 | isa = PBXGroup; 40 | children = ( 41 | 8115D01B265D057700CBC6FC /* GenericLocalPersistence */, 42 | 8115D01A265D057700CBC6FC /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 8115D01A265D057700CBC6FC /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 8115D019265D057700CBC6FC /* GenericLocalPersistence.framework */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 8115D01B265D057700CBC6FC /* GenericLocalPersistence */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 8115D029265D05A800CBC6FC /* Managers */, 58 | 8115D025265D058F00CBC6FC /* extension */, 59 | 8115D01C265D057700CBC6FC /* GenericLocalPersistence.h */, 60 | 8115D01D265D057700CBC6FC /* Info.plist */, 61 | ); 62 | path = GenericLocalPersistence; 63 | sourceTree = ""; 64 | }; 65 | 8115D025265D058F00CBC6FC /* extension */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 8115D026265D059B00CBC6FC /* Encodable.swift */, 69 | ); 70 | path = extension; 71 | sourceTree = ""; 72 | }; 73 | 8115D029265D05A800CBC6FC /* Managers */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 8115D02A265D05D400CBC6FC /* DefaultManager.swift */, 77 | 8115D02E265D05F600CBC6FC /* KeyChainManager.swift */, 78 | 8115D031265D060F00CBC6FC /* PlistManager.swift */, 79 | ); 80 | path = Managers; 81 | sourceTree = ""; 82 | }; 83 | /* End PBXGroup section */ 84 | 85 | /* Begin PBXHeadersBuildPhase section */ 86 | 8115D014265D057700CBC6FC /* Headers */ = { 87 | isa = PBXHeadersBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | 8115D01E265D057700CBC6FC /* GenericLocalPersistence.h in Headers */, 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | /* End PBXHeadersBuildPhase section */ 95 | 96 | /* Begin PBXNativeTarget section */ 97 | 8115D018265D057700CBC6FC /* GenericLocalPersistence */ = { 98 | isa = PBXNativeTarget; 99 | buildConfigurationList = 8115D021265D057700CBC6FC /* Build configuration list for PBXNativeTarget "GenericLocalPersistence" */; 100 | buildPhases = ( 101 | 8115D014265D057700CBC6FC /* Headers */, 102 | 8115D015265D057700CBC6FC /* Sources */, 103 | 8115D016265D057700CBC6FC /* Frameworks */, 104 | 8115D017265D057700CBC6FC /* Resources */, 105 | ); 106 | buildRules = ( 107 | ); 108 | dependencies = ( 109 | ); 110 | name = GenericLocalPersistence; 111 | productName = GenericLocalPersistence; 112 | productReference = 8115D019265D057700CBC6FC /* GenericLocalPersistence.framework */; 113 | productType = "com.apple.product-type.framework"; 114 | }; 115 | /* End PBXNativeTarget section */ 116 | 117 | /* Begin PBXProject section */ 118 | 8115D010265D057700CBC6FC /* Project object */ = { 119 | isa = PBXProject; 120 | attributes = { 121 | LastUpgradeCheck = 1240; 122 | TargetAttributes = { 123 | 8115D018265D057700CBC6FC = { 124 | CreatedOnToolsVersion = 12.4; 125 | LastSwiftMigration = 1240; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = 8115D013265D057700CBC6FC /* Build configuration list for PBXProject "GenericLocalPersistence" */; 130 | compatibilityVersion = "Xcode 9.3"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = 8115D00F265D057700CBC6FC; 138 | productRefGroup = 8115D01A265D057700CBC6FC /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | 8115D018265D057700CBC6FC /* GenericLocalPersistence */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | 8115D017265D057700CBC6FC /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXResourcesBuildPhase section */ 156 | 157 | /* Begin PBXSourcesBuildPhase section */ 158 | 8115D015265D057700CBC6FC /* Sources */ = { 159 | isa = PBXSourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 8115D032265D060F00CBC6FC /* PlistManager.swift in Sources */, 163 | 8115D027265D059B00CBC6FC /* Encodable.swift in Sources */, 164 | 8115D02F265D05F600CBC6FC /* KeyChainManager.swift in Sources */, 165 | 8115D02B265D05D400CBC6FC /* DefaultManager.swift in Sources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXSourcesBuildPhase section */ 170 | 171 | /* Begin XCBuildConfiguration section */ 172 | 8115D01F265D057700CBC6FC /* Debug */ = { 173 | isa = XCBuildConfiguration; 174 | buildSettings = { 175 | ALWAYS_SEARCH_USER_PATHS = NO; 176 | CLANG_ANALYZER_NONNULL = YES; 177 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 178 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 179 | CLANG_CXX_LIBRARY = "libc++"; 180 | CLANG_ENABLE_MODULES = YES; 181 | CLANG_ENABLE_OBJC_ARC = YES; 182 | CLANG_ENABLE_OBJC_WEAK = YES; 183 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 184 | CLANG_WARN_BOOL_CONVERSION = YES; 185 | CLANG_WARN_COMMA = YES; 186 | CLANG_WARN_CONSTANT_CONVERSION = YES; 187 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 188 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 189 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 190 | CLANG_WARN_EMPTY_BODY = YES; 191 | CLANG_WARN_ENUM_CONVERSION = YES; 192 | CLANG_WARN_INFINITE_RECURSION = YES; 193 | CLANG_WARN_INT_CONVERSION = YES; 194 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 195 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 196 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 198 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 199 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 200 | CLANG_WARN_STRICT_PROTOTYPES = YES; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | COPY_PHASE_STRIP = NO; 206 | CURRENT_PROJECT_VERSION = 1; 207 | DEBUG_INFORMATION_FORMAT = dwarf; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | ENABLE_TESTABILITY = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu11; 211 | GCC_DYNAMIC_NO_PIC = NO; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 220 | GCC_WARN_UNDECLARED_SELECTOR = YES; 221 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 222 | GCC_WARN_UNUSED_FUNCTION = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 14.4; 225 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 226 | MTL_FAST_MATH = YES; 227 | ONLY_ACTIVE_ARCH = YES; 228 | SDKROOT = iphoneos; 229 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 230 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 231 | VERSIONING_SYSTEM = "apple-generic"; 232 | VERSION_INFO_PREFIX = ""; 233 | }; 234 | name = Debug; 235 | }; 236 | 8115D020265D057700CBC6FC /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_ANALYZER_NONNULL = YES; 241 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_ENABLE_OBJC_WEAK = YES; 247 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 248 | CLANG_WARN_BOOL_CONVERSION = YES; 249 | CLANG_WARN_COMMA = YES; 250 | CLANG_WARN_CONSTANT_CONVERSION = YES; 251 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 252 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 253 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 254 | CLANG_WARN_EMPTY_BODY = YES; 255 | CLANG_WARN_ENUM_CONVERSION = YES; 256 | CLANG_WARN_INFINITE_RECURSION = YES; 257 | CLANG_WARN_INT_CONVERSION = YES; 258 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 259 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 260 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 261 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 262 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 263 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 264 | CLANG_WARN_STRICT_PROTOTYPES = YES; 265 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 266 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | COPY_PHASE_STRIP = NO; 270 | CURRENT_PROJECT_VERSION = 1; 271 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 272 | ENABLE_NS_ASSERTIONS = NO; 273 | ENABLE_STRICT_OBJC_MSGSEND = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu11; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 14.4; 283 | MTL_ENABLE_DEBUG_INFO = NO; 284 | MTL_FAST_MATH = YES; 285 | SDKROOT = iphoneos; 286 | SWIFT_COMPILATION_MODE = wholemodule; 287 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 288 | VALIDATE_PRODUCT = YES; 289 | VERSIONING_SYSTEM = "apple-generic"; 290 | VERSION_INFO_PREFIX = ""; 291 | }; 292 | name = Release; 293 | }; 294 | 8115D022265D057700CBC6FC /* Debug */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | CLANG_ENABLE_MODULES = YES; 298 | CODE_SIGN_STYLE = Automatic; 299 | DEFINES_MODULE = YES; 300 | DYLIB_COMPATIBILITY_VERSION = 1; 301 | DYLIB_CURRENT_VERSION = 1; 302 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 303 | INFOPLIST_FILE = GenericLocalPersistence/Info.plist; 304 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 305 | LD_RUNPATH_SEARCH_PATHS = ( 306 | "$(inherited)", 307 | "@executable_path/Frameworks", 308 | "@loader_path/Frameworks", 309 | ); 310 | PRODUCT_BUNDLE_IDENTIFIER = com.localpersistence; 311 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 312 | SKIP_INSTALL = YES; 313 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 314 | SWIFT_VERSION = 5.0; 315 | TARGETED_DEVICE_FAMILY = "1,2"; 316 | }; 317 | name = Debug; 318 | }; 319 | 8115D023265D057700CBC6FC /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | CLANG_ENABLE_MODULES = YES; 323 | CODE_SIGN_STYLE = Automatic; 324 | DEFINES_MODULE = YES; 325 | DYLIB_COMPATIBILITY_VERSION = 1; 326 | DYLIB_CURRENT_VERSION = 1; 327 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 328 | INFOPLIST_FILE = GenericLocalPersistence/Info.plist; 329 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 330 | LD_RUNPATH_SEARCH_PATHS = ( 331 | "$(inherited)", 332 | "@executable_path/Frameworks", 333 | "@loader_path/Frameworks", 334 | ); 335 | PRODUCT_BUNDLE_IDENTIFIER = com.localpersistence; 336 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 337 | SKIP_INSTALL = YES; 338 | SWIFT_VERSION = 5.0; 339 | TARGETED_DEVICE_FAMILY = "1,2"; 340 | }; 341 | name = Release; 342 | }; 343 | /* End XCBuildConfiguration section */ 344 | 345 | /* Begin XCConfigurationList section */ 346 | 8115D013265D057700CBC6FC /* Build configuration list for PBXProject "GenericLocalPersistence" */ = { 347 | isa = XCConfigurationList; 348 | buildConfigurations = ( 349 | 8115D01F265D057700CBC6FC /* Debug */, 350 | 8115D020265D057700CBC6FC /* Release */, 351 | ); 352 | defaultConfigurationIsVisible = 0; 353 | defaultConfigurationName = Release; 354 | }; 355 | 8115D021265D057700CBC6FC /* Build configuration list for PBXNativeTarget "GenericLocalPersistence" */ = { 356 | isa = XCConfigurationList; 357 | buildConfigurations = ( 358 | 8115D022265D057700CBC6FC /* Debug */, 359 | 8115D023265D057700CBC6FC /* Release */, 360 | ); 361 | defaultConfigurationIsVisible = 0; 362 | defaultConfigurationName = Release; 363 | }; 364 | /* End XCConfigurationList section */ 365 | }; 366 | rootObject = 8115D010265D057700CBC6FC /* Project object */; 367 | } 368 | -------------------------------------------------------------------------------- /GenericLocalPersistence.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GenericLocalPersistence.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GenericLocalPersistence/GenericLocalPersistence.h: -------------------------------------------------------------------------------- 1 | // 2 | // GenericLocalPersistence.h 3 | // GenericLocalPersistence 4 | // 5 | // Created by Riddhi Patel on 25/05/21. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for GenericLocalPersistence. 11 | FOUNDATION_EXPORT double GenericLocalPersistenceVersionNumber; 12 | 13 | //! Project version string for GenericLocalPersistence. 14 | FOUNDATION_EXPORT const unsigned char GenericLocalPersistenceVersionString[]; 15 | 16 | // In this header, you should import all the public headers of your framework using statements like #import 17 | 18 | 19 | -------------------------------------------------------------------------------- /GenericLocalPersistence/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | GenericLocalPersistence 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | 24 | 25 | -------------------------------------------------------------------------------- /GenericLocalPersistence/Managers/DefaultManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // defaultManager.swift 3 | // iOSGenricPods 4 | // 5 | // Created by Riddhi Patel on 21/05/21. 6 | // 7 | 8 | import UIKit 9 | public class DefaultManager{ 10 | public init(){ 11 | } 12 | public func saveValueInDefault(value: T, using key : String) { 13 | let encodedData = try! JSONEncoder().encode(value) 14 | UserDefaults.standard.setValue(encodedData, forKey: key) 15 | UserDefaults.standard.synchronize() 16 | } 17 | public func getValue(_ key: String) -> T? { 18 | if let data = UserDefaults.standard.data(forKey: key) 19 | { 20 | do{ 21 | let value = try? JSONDecoder().decode(T.self, from: data) 22 | return value 23 | } 24 | 25 | } 26 | 27 | return self as? T 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /GenericLocalPersistence/Managers/KeyChainManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KeyChainManager.swift 3 | // GenericLocalPersistence 4 | // 5 | // Created by Riddhi Patel on 25/05/21. 6 | // 7 | 8 | import UIKit 9 | import Security 10 | 11 | public class KeyChainManager { 12 | 13 | public init?() { 14 | } 15 | public func save(key: String, data: Data) -> OSStatus { 16 | let query = [ 17 | kSecClass as String : kSecClassGenericPassword as String, 18 | kSecAttrAccount as String : key, 19 | kSecAttrService as String:key, 20 | 21 | kSecValueData as String : data ] as [String : Any] 22 | 23 | SecItemDelete(query as CFDictionary) 24 | 25 | return SecItemAdd(query as CFDictionary, nil) 26 | } 27 | 28 | public func load(key: String) -> Data? { 29 | let query = [ 30 | kSecClass as String : kSecClassGenericPassword, 31 | kSecAttrAccount as String : key, 32 | kSecAttrService as String:key, 33 | 34 | kSecReturnData as String : kCFBooleanTrue!, 35 | kSecMatchLimit as String : kSecMatchLimitOne ] as [String : Any] 36 | 37 | var dataTypeRef: AnyObject? = nil 38 | 39 | let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &dataTypeRef) 40 | 41 | if status == noErr { 42 | return dataTypeRef as! Data? 43 | } else { 44 | return nil 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /GenericLocalPersistence/Managers/PlistManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlistManager.swift 3 | // GenericLocalPersistence 4 | // 5 | // Created by Riddhi Patel on 25/05/21. 6 | // 7 | 8 | import UIKit 9 | 10 | //MARK:ERROR ENUM 11 | enum PlistError: Error { 12 | case failedToWrite 13 | case fileDoesNotExist 14 | } 15 | public class plistManager 16 | { 17 | //MARK:VARIABLE DECLRATION 18 | private let fileManager = FileManager.default 19 | let name:String 20 | 21 | //MARK:INITIALIZATION 22 | public init?(named :String) { 23 | self.name = named 24 | } 25 | 26 | public func defaultPath() -> String{ 27 | let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String 28 | return paths.appending("/\(self.name).plist") 29 | } 30 | 31 | //MARK:SAVE DICTIONARY VALUE IN PLIST 32 | 33 | public func saveDatatoPlist(value: T, using key : String) { 34 | let fileManager = FileManager.default 35 | if (!(fileManager.fileExists(atPath: defaultPath()))) 36 | { 37 | do { 38 | let bundlePath : NSString = Bundle.main.path(forResource: self.name, ofType: "plist")! as NSString 39 | try fileManager.copyItem(atPath: bundlePath as String, toPath: defaultPath()) 40 | }catch { 41 | print(error) 42 | } 43 | } 44 | let plistDict:NSMutableDictionary = NSMutableDictionary(contentsOfFile: defaultPath())! 45 | if(type(of: value) is AnyClass){ 46 | plistDict.setValue(value.dictionary, forKey: key) 47 | } 48 | else { 49 | plistDict.setValue(value, forKey: key) 50 | } 51 | plistDict.write(toFile: defaultPath(), atomically: true) 52 | } 53 | 54 | //MARK:GET DICTIONARY VALUE IN PLIST 55 | public func getDictionary(key : String) -> T? { 56 | 57 | guard fileManager.fileExists(atPath: defaultPath()) else { 58 | return self as? T 59 | } 60 | let valueOfDictionary = NSDictionary(contentsOfFile: defaultPath()) 61 | let value1 = valueOfDictionary?.object(forKey: key) 62 | print(value1!) 63 | return value1 as? T 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /GenericLocalPersistence/extension/Encodable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Encodable.swift 3 | // GenericLocalPersistence 4 | // 5 | // Created by Riddhi Patel on 25/05/21. 6 | // 7 | 8 | 9 | import Foundation 10 | extension Encodable { 11 | var dictionary: [String: Any]? { 12 | guard let data = try? JSONEncoder().encode(self) else { return nil } 13 | return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? [String: Any] } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mindinventory 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GenericLocalPersistence 2 | 3 | GenericLocalPersistence is a clean and easy-to-use code that is useful for integrating local storage like, 4 | 5 | * **UserDefaults** 6 | * **PList** 7 | * **Keychain** 8 | 9 | Read more from [MEDIUM](https://medium.com/mindful-engineering/generic-local-persistence-8b4cfa5dbf7d) 10 | 11 | ## Installation 12 | 13 | From CocoaPods 14 | First, add the following line to your Podfile 15 | 16 | ```bash 17 | pod install 'GenericLocalPersistence', '~> 0.0.1’ 18 | 19 | pod 'GenericLocalPersistence', :git => 'https://github.com/Riddhi-mi/GenericLocalPersistence.git' 20 | ``` 21 | 22 | 23 | # Usage of UserDefault 24 | 25 | import GenericLocalPersistence 26 | 27 | ### Set & Get value from User Default 28 | 29 | ```python 30 | DefaultManager().saveValueInDefault(value: "TestValue", using: "TestKey") 31 | let valueFetch:String = DefaultManager().getValue("TestKey") ?? "" 32 | ``` 33 | 34 | # Usage of Plist 35 | 36 | import GenericLocalPersistence 37 | 38 | ### Set & Get value from plist file 39 | Replace "userDetails" with custom name for creating plist file to store data 40 | 41 | ```python 42 | private let managerPlist = plistManager(named: "userDetails") 43 | ``` 44 | 45 | ```python 46 | managerPlist?.saveDatatoPlist(value: "TestString Value", using: "TestKey") 47 | let stringValue :String = managerPlist?.getDictionary(key: "TestKey") ?? "" 48 | ``` 49 | 50 | ## Usage of KeyChain 51 | import GenericLocalPersistence 52 | 53 | ### Set & Get value from KeyChain file 54 | 55 | 56 | #### Store password value 57 | 58 | ```python 59 | let passWordString = textPassword?.text?.data(using: .utf8, allowLossyConversion: false) ?? Data() 60 | let passwordStatus = KeyChainManager()?.save(key: "com.appBundleID.password", data: passWordString) 61 | 62 | //Retrive data 63 | 64 | if let receivedData = KeyChainManager()?.load(key: "com.appBundleID.password") { 65 | let data = String(decoding: receivedData, as: UTF8.self) 66 | print("result: ", data) 67 | } 68 | ``` 69 | 70 | #### Store username value 71 | ```python 72 | 73 | let userNameString = textName?.text?.data(using: .utf8, allowLossyConversion: false) ?? Data() 74 | let emailStatus = KeyChainManager()?.save(key: "com.appBundleID.email", data: userNameString) 75 | 76 | //Retrive data 77 | 78 | if let data = KeyChainManager()?.load(key: "com.appBundleID.email") { 79 | let data = String(decoding: data, as: UTF8.self) 80 | print("result: ", data) 81 | } 82 | ``` 83 | 84 | ## NOTE 85 | ```python 86 | Replace "com.appBundleID" with your project bundleID for KeyChain integration 87 | Define the dataType in which you want to fetch the value and that’s the way you can get the stored value. 88 | ``` 89 | 90 | 91 | 92 | ## Contributing 93 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 94 | 95 | Please make sure to update tests as appropriate. 96 | 97 | ## License 98 | GenericLocalPersistence is [MIT-licensed](/LICENSE). 99 | --------------------------------------------------------------------------------