# Cannot open encrypted database with SQLCipher 4

**URL:** <https://discuss.zetetic.net/t/cannot-open-encrypted-database-with-sqlcipher-4/3654>\
**Category:** SQLCipher\
**Created:** [May 10, 2019, 1:41am UTC](https://discuss.zetetic.net/t/cannot-open-encrypted-database-with-sqlcipher-4/3654 "2019-05-10T01:41:19Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mmoore](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/mmoore/32/858_2.png) [@mmoore](https://discuss.zetetic.net/u/mmoore)\
**Post date:** [May 10, 2019, 4:42pm UTC](https://discuss.zetetic.net/t/cannot-open-encrypted-database-with-sqlcipher-4/3654/4 "2019-05-10T16:42:50Z")

</div>

@jdleung

> [@jdleung](#):
>
> pod ‘Google-Mobile-Ads-SDK’

This is the culprit. If you look at their pod spec, they are linking sqlite3.

> <https://github.com/CocoaPods/Specs/blob/master/Specs/5/9/a/Google-Mobile-Ads-SDK/7.43.1/Google-Mobile-Ads-SDK.podspec.json#L26>

If both SQLCipher and a standard version of SQLite are linked, this can lead to undefined behavior.

Our recommendation would be to remove any other pods that depend on SQLite.

Alternatively, there is some guidance in these posts on how to ensure SQLCipher is preferred when linking:

**Note: This is considered unsupported**

> [@Databases not keying properly in iOS 10?](https://discuss.zetetic.net/t/databases-not-keying-properly-in-ios-10/1666/10):
>
> @sjlombardo after doing as you said, the build now fails with the following error ld: library not found for -lsqlcipher clang: error: linker command failed with exit code 1 (use -v to see invocation)

> [@Important Advisory: SQLCipher with Xcode 8 and new SDKs](https://discuss.zetetic.net/t/important-advisory-sqlcipher-with-xcode-8-and-new-sdks/1688):
>
> Note: Updated to clarify that this guidance applies to all projects built with Xcode 8, including for non-iOS targets). Apple has recently released XCode 8, along with new SDKs (e.g. iOS 10, watchOS 3, mac OS, tvOS), with many new features and enhancements. The majority of projects that include SQLCipher should have no problems after upgrading. However, there are some important changes and edge cases, so we have prepared the following important recommendations for all SQLCipher developers upgra…

Specifically in your scenario, since you’re using cocoa pods with `use_frameworks` you’ll want to put this as the first item in your target’s Build Settings \> Other Linker Flags: `-framework SQLCipher` as recommended in the second post. We’d also recommend following the guidance in that second post related to ensuring that SQLCipher is properly linked at runtime.

---

_[View the full topic](https://discuss.zetetic.net/t/cannot-open-encrypted-database-with-sqlcipher-4/3654)._
