From 61cdac2d9f36143f144e484b7542b6d5ed842bb1 Mon Sep 17 00:00:00 2001 From: Matus Mistrik Date: Mon, 18 Mar 2024 12:31:15 +0100 Subject: [PATCH] feat: GoodPersistance udpate & added PrivacyInfo.xcprivacy --- .../xcshareddata/swiftpm/Package.resolved | 17 +++++++--- .../Managers/CacheManager/CacheManager.swift | 2 +- .../RequestManager/RequestManager.swift | 2 ++ Package.resolved | 22 +++++++++++-- Package.swift | 5 +-- .../Providers/CacheProvider.swift | 15 +++------ Sources/PrivacyInfo.xcprivacy | 31 +++++++++++++++++++ 7 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 Sources/PrivacyInfo.xcprivacy diff --git a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 721aa1d..0465579 100644 --- a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/GoodRequest/GoodNetworking.git", "state": { "branch": null, - "revision": "cc11824e56c4da0fd7b4002be2c7a75459a9d051", - "version": "2.4.0" + "revision": "47b616af6b839166cdac357d02cbce6b65c959c0", + "version": "2.5.0" } }, { @@ -42,8 +42,17 @@ "repositoryURL": "https://github.com/GoodRequest/GoodPersistence.git", "state": { "branch": null, - "revision": "bf82128545d0a78603c764c6c164303e3f61f7fc", - "version": "1.1.0" + "revision": "841f777b44a6061e3a6f4e01ffb1e36af2dfe13f", + "version": "2.1.0" + } + }, + { + "package": "KeychainAccess", + "repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess.git", + "state": { + "branch": null, + "revision": "84e546727d66f1adc5439debad16270d0fdd04e7", + "version": "4.2.2" } }, { diff --git a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/CacheManager/CacheManager.swift b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/CacheManager/CacheManager.swift index 81aa1ae..9292aa9 100644 --- a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/CacheManager/CacheManager.swift +++ b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/CacheManager/CacheManager.swift @@ -15,7 +15,7 @@ final class CacheManager: CacheManagerType { @UserDefaultValue("fullName", defaultValue: nil) var fullName: String? - @UserDefaultValue("gender", defaultValue: 0) + @KeychainValue("gender", defaultValue: 0) var gender: Int @UserDefaultValue("favoriteColor", defaultValue: "Red") diff --git a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/RequestManager/RequestManager.swift b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/RequestManager/RequestManager.swift index 6002ef4..719bc4c 100644 --- a/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/RequestManager/RequestManager.swift +++ b/AppDebugMode-iOS-Sample/AppDebugMode-iOS-Sample/Managers/RequestManager/RequestManager.swift @@ -34,7 +34,9 @@ final class RequestManager: RequestManagerType { init(baseServer: ApiServer) { LoggingEventMonitor.maxVerboseLogSizeBytes = 1000000 let monitor = LoggingEventMonitor(logger: nil) + #if DEBUG StandardOutputService.shared.connectCustomLogStreamPublisher(monitor.subscribeToMessages()) + #endif session = NetworkSession(baseUrl: baseServer.rawValue, configuration: .init(urlSessionConfiguration: .default, interceptor: nil, serverTrustManager: nil, eventMonitors: [monitor])) } diff --git a/Package.resolved b/Package.resolved index 4a13a85..aef9319 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,26 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/GoodRequest/GoodPersistence.git", "state" : { - "revision" : "780e03a1e21948b114d7af3bc0cfe0d8aecae4c0", - "version" : "1.0.2" + "revision" : "841f777b44a6061e3a6f4e01ffb1e36af2dfe13f", + "version" : "2.1.0" + } + }, + { + "identity" : "keychainaccess", + "kind" : "remoteSourceControl", + "location" : "https://github.com/kishikawakatsumi/KeychainAccess.git", + "state" : { + "revision" : "84e546727d66f1adc5439debad16270d0fdd04e7", + "version" : "4.2.2" + } + }, + { + "identity" : "swiftui-introspect", + "kind" : "remoteSourceControl", + "location" : "https://github.com/siteline/swiftui-introspect", + "state" : { + "revision" : "0cd2a5a5895306bc21d54a2254302d24a9a571e4", + "version" : "1.1.3" } } ], diff --git a/Package.swift b/Package.swift index eeca916..26d3ce3 100644 --- a/Package.swift +++ b/Package.swift @@ -13,7 +13,7 @@ let package = Package( targets: ["AppDebugMode"]), ], dependencies: [ - .package(url: "https://github.com/GoodRequest/GoodPersistence.git", .upToNextMajor(from: "1.0.0")), + .package(url: "https://github.com/GoodRequest/GoodPersistence.git", .upToNextMajor(from: "2.1.0")), .package(url: "https://github.com/siteline/swiftui-introspect", from: "1.0.0"), ], targets: [ @@ -25,7 +25,8 @@ let package = Package( .product(name: "GoodPersistence", package: "GoodPersistence"), .product(name: "SwiftUIIntrospect", package: "swiftui-introspect"), ], - path: "Sources/AppDebugMode" + path: "Sources", + resources: [.copy("PrivacyInfo.xcprivacy")] ), .testTarget( name: "AppDebugModeTests", diff --git a/Sources/AppDebugMode/Providers/CacheProvider.swift b/Sources/AppDebugMode/Providers/CacheProvider.swift index d6d5451..6681b7a 100644 --- a/Sources/AppDebugMode/Providers/CacheProvider.swift +++ b/Sources/AppDebugMode/Providers/CacheProvider.swift @@ -7,6 +7,7 @@ import Foundation import GoodPersistence +import KeychainAccess final class CacheProvider { @@ -128,8 +129,7 @@ private extension CacheProvider { keychainValues[key] = receiveKeychainValueFromPropertyList( key: key, valueType: decodable.self, - defaultValue: defaultValueChild.value, - accessibility: childMirror.children.first(where: { $0.label == "accessibility" })?.value as? KeychainItemAccessibility + defaultValue: defaultValueChild.value ) } } @@ -137,21 +137,14 @@ private extension CacheProvider { func receiveKeychainValueFromPropertyList( key: String, valueType: T.Type, - defaultValue: Any, - accessibility: KeychainItemAccessibility? + defaultValue: Any ) -> String { - guard let data = KeychainWrapper.standard.data( - forKey: key, - withAccessibility: accessibility - ) else { + guard let value = try? Keychain.default.get(key) else { let defaultValueCodable = defaultValue as! Codable // Return default value if data cannot be retrieved from Keychain return formatValue(value: defaultValueCodable) } - // Decode the data and get the value, or return default value if decoding fails - let value = (try? PropertyListDecoder().decode(Wrapper.self, from: data))?.value - return formatValue(value: value) } diff --git a/Sources/PrivacyInfo.xcprivacy b/Sources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..9c3364e --- /dev/null +++ b/Sources/PrivacyInfo.xcprivacy @@ -0,0 +1,31 @@ + + + + + NSPrivacyTracking + + NSPrivacyTrackingDomains + + NSPrivacyCollectedDataTypes + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + +