添加SQLCipher 到项目中

文章目录

  • 一、克隆下载SQLCipher
  • 二、手动导入
    • 1. 生成sqlite3.c
    • 2. 在项目中添加命令
    • 3. 添加 Security.framework
  • 三、CocoaPods导入

SQLCipher官方地址

一、克隆下载SQLCipher

$ cd ~/Documents/code
$ git clone https://github.com/sqlcipher/sqlcipher.git

二、手动导入

1. 生成sqlite3.c

打开下载的SQLCipher,运行脚本命令

$ cd sqlcipher
$ ./configure --with-crypto-lib=none
$ make sqlite3.c

sqlite3.csqlite3.h 导入到项目中
添加SQLCipher 到项目中_第1张图片

2. 在项目中添加命令

  1. 在build setting 中 “Other C Flags.” 下添加如下命令:
    -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=3 -DSQLCIPHER_CRYPTO_CC -DNDEBUG.

添加SQLCipher 到项目中_第2张图片

  1. 如果是swift项目添加"Preprocessor Macros"的 Release settings 下添加 SQLITE_HAS_CODEC=1
    添加SQLCipher 到项目中_第3张图片

3. 添加 Security.framework

在Link Binary With Libraries添加 Security.framework

添加SQLCipher 到项目中_第4张图片

三、CocoaPods导入

Podfile 文件添加下列内容

platform :ios, '10.0'

target 'SQLCipherApp' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  pod 'SQLCipher', '~>4.0'
end

你可能感兴趣的:(swift学习,ios)