XCode9-beta:函数的隐式声明'sqlite3_key'

XCode9-beta: Implicit declaration of function 'sqlite3_key'

我在 EncryptedStore SQLCipher wrapper 加密核心数据时遇到问题。
我为此添加了 C 标志:

Debug = -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -DSQLITE_THREADSAFE -DSQLCIPHER_CRYPTO_CC
Release = -DSQLITE_HAS_CODEC -DNDEBUG -DSQLITE_OS_UNIX=1 -DSQLITE_TEMP_STORE=2 -DSQLITE_THREADSAFE -DSQLCIPHER_CRYPTO_CC

并将其用作:

func encryptedCoordinator() -> NSPersistentStoreCoordinator {
  var coordinator:NSPersistentStoreCoordinator?
  let ops:[String : Any] =    [NSMigratePersistentStoresAutomaticallyOption:(true),                                              NSInferMappingModelAutomaticallyOption:(true), EncryptedStorePassphraseKey:sqlCipherKey, EncryptedStoreDatabaseLocation:self.sqliteFileURL()]

  do {
      coordinator = try EncryptedStore.make(options: ops, managedObjectModel: self.managedObjectModel, error: ())
    }catch {
      fatalError("Error opening encrypted DB: \(error)")
    }
    return coordinator!
  }

它在 XCode8 中运行良好,但在 XCode9-beta.
中出现错误 错误行:

- (BOOL)changeDatabasePassphrase:(NSString *)passphrase error:(NSError *__autoreleasing*)error {
  BOOL result;
  int status;
  if ([passphrase length] > 0) {
    // Password provided, use it to key the DB
    const char *string = [passphrase UTF8String];
    status = sqlite3_rekey(database, string, (int)strlen(string));//ERROR line
    string = NULL;
    passphrase = nil;
  } else {
    // No password
    status = SQLITE_OK;
  }
  result = status == SQLITE_OK;
  if (result) {
    result = [self checkDatabaseStatusWithError:error];
  }
return result && (*error == nil);
}

函数在 EncryptedStroe/sqlite3.h 中声明为:

SQLITE_API int sqlite3_rekey(
sqlite3 *db,                   /* Database to be rekeyed */
  const void *pKey, int nKey     /* The new key */
);
SQLITE_API int sqlite3_rekey_v2(
  sqlite3 *db,                   /* Database to be rekeyed */
  const char *zDbName,           /* Name of the database */
  const void *pKey, int nKey     /* The new key */
);

我认为问题是导入 EncryptedStore.m 文件: #import <sqlite3.h>

它使用了<>所以导入了系统sqlite库,不包含这些函数。通过将 <> 更改为 "" 一切都可以正常编译。

找到另一个解决方案here

主要是更改 Header 搜索路径。
尝试将其更改为 $(PROJECT_DIR)/sqlcipher/src
$(PROJECT_DIR)/sqlcipher
(即从路径中删除 /src)。”对我有用。