GRDB/SQLCipher crash, release builds only [Solved]

I ran into this issue recently and it cost me some hair to resolve. Debug releases of my app were working great, but as soon as I tried a TestFlight build they crashed instantly. Crash reports showed the crash was in GRDB and libsqlite3.dylib.

It turns out that if you have multiple libraries using sqlite, it's critical that SQLCipher be linked first.

Since lots of 3rd party libs use sqlite (in my app, I have both MS App Center and Sematext/Logsene), I wonder if it would make sense to note this in the GRDB/SQLCipher docs? I found this info buried in SQLCipher FAQ only after a lot of debugging.

Update (in response to @gwendal.roue):

In fact, the SQLCipher docs state that "an application should never link in other versions of SQLite". Unfortunately, this is unrealistic. In the same doc, they state:

"One way to prevent undefined linking behavior or silent failures is to ensure that SQLCipher is linked into the application first."

The docs outline four ways to do this, depending on your situation, but most users of GRDB/SQLCipher will simply want to go into Build Settings for their target and edit Other Linker Flags to make sure that -framework SQLCipher comes first.

Hello @philmitchell,

Thanks for your feedback. Can we run the last meters and make this thread a great and helpful one?

I've seen many people having trouble when both SQLite and SQLCipher are linked, but I've never been sure that (1) this is a supported configuration, (2) granted some specific setup.

I found this info buried in SQLCipher FAQ only after a lot of debugging.

And it's still pretty much buried. An explicit link would be marvelous.

it's critical that SQLCipher be linked first

An explicit how-to guide would be great, if you have time.

In this conversion, I personally did learn that you found one solution that works for you. But I still don't know if it works for other people, and I don't know how to achieve it.

People who will search on Google and find this conversation will keep on scratching their head, wondering how to deal with this issue. Unless... someone takes the time to write down some clear answers. Will you be this helpful person?

I removed the [Solved] tag in the thread title, because the solution, it it exists, is not made explicit yet.

Happy to help, GRDB is awesome! I've edited the original post ... thanks @gwendal.roue!

1 Like

That's really great, @philmitchell, thank you very much for your detailed post! All useful information gathered in a single place :heart: I'll be able to send a link to this thread whenever some GRDB user asks this question (and users of FMDB, SQLite.swift, raw SQLite, etc will enjoy it as well)!

1 Like
Terms of Service

Privacy Policy

Cookie Policy