JSON Store can't read when setting password

50 Views Asked by At

I use password to open collection like below:

let options = JSONStoreOpenOptions()
            options.username = username
            options.password = paz
          do {
              try JSONStore.sharedInstance().openCollections([store], with: options)
          } catch let error as NSError {
            print(error)
          }

When I find with Id key, can't decode JSON return and I got Error Domain=JSON_STORE_EXCEPTION Code=22 "(null)". I tested without password to open collection, It works well.

 let decoder = JSONDecoder()
        do {
               if let results = try store.find(withIds: [1], andOptions: nil) as? [[String: Any]],
                let result: [String: Any] = results.first,
                let json: [String: Any] = result["json"] as? [String: Any] {
                let jsonData = try JSONSerialization.data(withJSONObject: json, options: [])
                return try decoder.decode(type, from: jsonData)
            }
        } catch let error {
            print(error)
        }

Is there anything do I missed out for using with password?

1

There are 1 best solutions below

0
thinzar On

I solved the problem. It is because of SQLCipher and sqlite both installed in project.If SQLCipher and sqlite both installed, need to set sqlite after SQLCipher in OTHER_LDFLAGS.