-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build fails with SQLCipher due to calls not yet available in SQLCipher #546
Comments
I've got no experience with SQLCipher. Will it eventually catch up with a more recent version of SQLite? Not sure what would be a good solution in this case. More conditionals would make the build even more complicated. |
I am sorry, I am a new dev. May you please help me how can I use SQLiteCipher.swift (https://github.com/stephencelis/SQLiteCipher.swift) My purpose is make a key for access my sqlite database, I want to prevent someone access to my database. I am waiting for your help or any suggestion about this problem. Thank sir so much. |
@leminhtuan2015 SQLiteCipher is deprecated. The upcoming 0.11.1 release of SQLite.swift will make the integration easier (at least if you use CocoaPods in your project). |
@jberkel Thank sir so much, I am waiting for the upcoming 0.11.1 release so that I can use SQLiteCipher.swift , and by the way, I am using your SQLite.swift by CocoaPods, that is so great Thank you sir! |
It's been released now, please give it a try: |
@jberkel Hello sir, I am trying your sqlcipher function: let db = try Connection("path/to/db.sqlite3") But i seem not working for me, SO please give me some ideal. I already have a "encrypted.sqlite" and I encrypted my sqlite file by using sqlcipher on MacOs terminal, the method I do is that: I use "encrypted.sqlite" in my IOS swift app, when I connect to the "encrypted.sqlite" by using "try db.key("secret")" nothing happen, I cannot connect to database anymore Please help. Thank Sir so much. |
@leminhtuan2015 I've added some tests to make sure this functionality works as expected. Have a look at Do you use the exact same passphrase for encrypting and decrypting? Also make sure to read the API docs at: |
Hi Sir.
Below are all the things I did, Please tell me if I wrong anything. Step 1: Create a "encrypted.sqlite" in the terminal of Mac OSX (macOS Sierra 10.12.1)
=> After that I got a "encrypted.sqlite" file. Step 2: Copy "encrypted.sqlite" to my bundle of IOS Swift app. Step 3: Use SQLite.swift/SQLCipher
NOTICE: "(Constant.DOCUMENT_PATH)/(Config.DATABASE_NAME)" is the path to "encrypted.sqlite" and my everything work well before I use pod 'SQLite.swift/SQLCipher', And now when run project i just only see the log in console of XCode is "Connected ok" and I Can NOT see "key ok" neither "Error" Please give me some ideal, Thank Sir so much. |
Strange, looks like you've done everything correctly – if there's a problem decrypting the database the code should throw. Maybe try stepping through the code in a debugger? I would also remove the |
Hi Sir. I am so sorry. Because of I run my project on simulator so that I got above problem. Please give me some advances, Thank sir so much |
Can you post the full error output? |
Hi Sir. I am new at Swift. The way i did is that : do{ And i got all in console: Connected Ok |
Remove the the catch statement, and run again |
Sorry Sir. When i remove catch statement i can not run project because i got error ": Errors thrown from here are not handled" When i use try! db.key("testkey") i got => fatal error: 'try!' expression unexpectedly raised an error: not an error: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 178 Sorry but please help solve it |
Sorry I'm not sure how your code ends up in this error condition. The result code is 0, which means "no error" (that's what it says "raised an error: not an error") I'm not sure what else you can try. Does everything work as expected with non-encrypted databases? |
Yes sir, Everything work great when i use non-encrypted databases I really need cipher my database, I tried so hard to this expect and this is the final step, please help me, Thank sir a lot. |
Maybe try using |
Hi Sir, I just find out that the error occur depending on the devices When I use non-encrypted databases => my app work great on all Simulator, Iphone 4s(IOS version 9.3.5) and Iphone 5s (version 10.1.1) But when I use encrypted databases ( I use try! db.key("testkey") ) =>
|
On simulator, nothing happens means it works? Which simulator did you try? |
I try on Simulator Iphone 5s Version 10.0 (SimulatorApp-700.14 ) |
Sorry sir, nothing happens NOT means it work, It mean i got no error and still can not connect to database. |
What do you mean you can't connect to the database? |
I try on Simulator Iphone 5s Version 10.0 => My app not crashing and i got no error, But my app not print "Key Ok" in console as below:
My app just only print "Connected Ok" and Not print "Key Ok" and with the same above code:
Sorry for taking so much time of Sir , but Just only sir can help me. |
Does it print |
Sir. It is NOT print anything on simulator BUT "Connected Ok" |
Try the following in the simulator: do {
let db = try Connection("(Constant.DOCUMENT_PATH)/(Config.DATABASE_NAME)")
print("Connected Ok")
try db.key("mykey") // Throw error here
fatalError("Key Ok")
} catch let error as NSError {
fatalError("error: \(error)")
}
fatalError("last") |
I tried and above code got error in catch block: |
Sorry sir, I tried and above code on simulator i got NO error Because github auto remove splash on comment : "\(Constant.DOCUMENT_PATH)/(Config.DATABASE_NAME)" Github comment not show "\" => I paste your code on my app > i got "Error Domain..." BUT now I try with correct path to database and got NO error But still can not get print "Key ok" |
Sorry sir, I tried and above code on simulator i got NO error Because github auto remove splash on comment : "\(Constant.DOCUMENT_PATH)/(Config.DATABASE_NAME)" Github comment not show "\" Sir 's code is: "(Constant.DOCUMENT_PATH)/(Config.DATABASE_NAME)" => I paste your code on my app > i got "Error Domain..." BUT now I try with correct path to database and got NO error But still can not get print "Key ok" |
You need to figure out what your code is doing. Don't rely on Remove the |
I really thank Sir for supporting. I will try debug, Really thank sir. |
Hi Sir. When i use debug i got error code 21 on this function (the function of SQLite.swift) |
OK, this is helpful. Looks like the error code got obscured, 21 is https://sqlite.org/rescode.html#misuse And the debugger screenshot seems to indicate that you're calling the db code from another thread than the main thread (Thread 20). Are you opening the db as a result of async work such as a web request? For now, to keep things simple I would open the db as early as possible in your application, for instance in the |
Hi Sir, Good morning. Sir are right. I am calling the database method from async
Because i thought when I use background thread for query database so that will not affect my UI.
|
So sorry sir. I add a new symbolic breakpoint to sqlite3MisuseError But debugger not stoping . May sir please TeamViewer help me at weekend. Please!!! |
Where is the database located on the device? Is it in a writable location? Try changing your
Run |
Oh WOW. Thank Sir so much. It work great now. So Could Sir please tell me what did you fix to make it work? Will Sir update to pod 'SQLite.swift', '~> 0.11.2' ? Really really...Thank Sir!!!, |
Glad it works now, that was a tricky one :) The valid key check wrote to the database to make sure the key is correct (it performed a There will be a new release soon, but not sure exactly when. |
Thank Sir so much. By the way, It is still working great when I query or make connection in background thread. Please! May I have your email or skype to keep contact. So So thank sir ! |
Good to hear! In general, accessing the db from a background thread should work since access to the database is automatically serialized with a queue by SQLite.swift. There are some functions (like Drop me a mail if you want: jan (at) berkel (dot) fr. |
Thank Sir so much!!! Have a nice day!!! |
Hi, I have just went through the above discussion but I couldn't fix the same issue. It will be helpful if you have any solution on below : Issue : connectionListDB = try Connection(path) I'm invoking method containing above 2 lines from AppDelegate (tried from both main and global thread) but the app is stay at second line of above codes and show the below error. No crashes, instead app is just stay at Launch screen. If I comment second line for encryption, everything works fine including all operation with SQLite.Swift. Error log: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) Note : I have enabled Allow Arbitrary Loads in my info.list and I also tried by removing this key from plist. Regards, |
commit 336faa1 on Oct 8 added calls to
sqlite3_expanded_sql
andsqlite3_trace_v2
.These are available in sqlite3 version 3.14, but not earlier versions. If you use SQLCipher upon which SQLiteCipher.swift is dependent, you get link errors because the version of sqlite3 used by SQLCipher is earlier than 3.14.
The text was updated successfully, but these errors were encountered: