             kSecClass as String: kSecClassKey,
             kSecAttrKeyClass as String: kSecAttrKeyClassPrivate
         ]
+
+        #if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+        if let accessGroup = self.storageParams.accessGroup {
+            query[kSecAttrAccessGroup] = accessGroup
+        }
+        #endif
     #elseif os(macOS)
         let query: [String: Any] = [
             kSecClass as String: kSecClassGenericPassword,


            kSecMatchLimit as String: kSecMatchLimitAll
        ]
    #elseif os(macOS)
        let query: [String: Any] = [
            kSecClass as String: kSecClassGenericPassword,

            kSecAttrApplicationLabel as String: nameData,
            kSecAttrApplicationTag as String: tagData
        ]

        #if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
        if let accessGroup = self.storageParams.accessGroup {
            query[kSecAttrAccessGroup] = accessGroup
        }
        #endif
    #elseif os(macOS)
        let query: [String: Any] = [
            kSecClass as String: kSecClassGenericPassword,
