# libCrypto on iOS and simulator

**URL:** <https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140>\
**Category:** Issues\
**Created:** [September 17, 2014, 12:14am UTC](https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140 "2014-09-17T00:14:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![XPlatform](https://avatars.discourse-cdn.com/v4/letter/x/e68b1a/32.png) [@XPlatform](https://discuss.zetetic.net/u/XPlatform)\
**Post date:** [September 17, 2014, 12:14am UTC](https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140/1 "2014-09-17T00:14:55Z")

</div>

I have sqlcipher building ok for ios builds, but when I try to build for simulator link fails with OpenSSL libcrypto. It lacks the architecture required for simulator (i386 I think). Any ideas on how to fix this? It seems when I add i386 to the OpenSSL Xcode target the library doesn’t build properly.

---

<div class="post-metadata">

**Author:** ![wgray](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/wgray/32/843_2.png) [@wgray](https://discuss.zetetic.net/u/wgray)\
**Post date:** [September 17, 2014, 2:17am UTC](https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140/2 "2014-09-17T02:17:10Z")

</div>

@XPlatform Hm, the ARCHS setting might need to be updated to standard archs (or cleared out, for automatic arch selection?) Right now we’ve got it set to `$(ARCHS_STANDARD_INCLUDING_64_BIT)`, which may be the problem. I’ll have to give it a shot and see, been a hot second, we use CommonCrypto when building for iOS and OS X.

I suspect you’d be better off linking against `Security.framework` and building SQLCipher with CommonCrypto as the crypto provider instead of OpenSSL. This is quite a bit simpler than configuring your build to use OpenSSL and you get the benefit of hardware acceleration (an enormous advantage, hard to understate).

For instance, in the `sqlcipher.xcodeproj` file in the [SQLCipher Git repo](https://github.com/sqlcipher/sqlcipher/) has an amalgamation target with a Run Script phase that sets the build up for CommonCrypto:

```auto
./configure --enable-tempstore=yes --with-crypto-lib=commoncrypto CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2"
make sqlite3.c
exit 0

```

The `sqlcipher` target links against `Security.framework` accordingly.

---

<div class="post-metadata">

**Author:** ![XPlatform](https://avatars.discourse-cdn.com/v4/letter/x/e68b1a/32.png) [@XPlatform](https://discuss.zetetic.net/u/XPlatform)\
**Post date:** [September 17, 2014, 2:49am UTC](https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140/3 "2014-09-17T02:49:40Z")

</div>

Wow - that solves it. I had no idea I could use commoncrypto. The instructions at github only discuss getting openssl built. Very happy to get rid of that messy part of my build.

Thanks!

---

<div class="post-metadata">

**Author:** ![wgray](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/wgray/32/843_2.png) [@wgray](https://discuss.zetetic.net/u/wgray)\
**Post date:** [September 17, 2014, 3:29pm UTC](https://discuss.zetetic.net/t/libcrypto-on-ios-and-simulator/140/4 "2014-09-17T15:29:41Z")

</div>

Yeah, ironically it’s OpenSSL that’s more widely available to folks on Unix-like systems but it can also be a lot harder to work with configuration-wise. Might be time we took the OpenSSL bits out of the iOS integration tutorial now that we’ve switched the project file over.

There are three crypto providers currently available: `openssl`, `commoncrypto`, and `libtomcrypt`.
