ios - Xcode 构建错误 - “函数 'sqlite3_key' 的隐式声明在 C99 中无效”
问题描述
我正在将一个大型 iOS 应用程序模块化,比如说,MyAppWithDatabase
分成两个模块(即项目)。因此,我将一个主项目MyApp
作为主机,并将一个链接MyDataPlatform
作为同一工作区下的框架MyApp.xcworkspace
。当为目标集成SQLCipher
pod时它工作正常,但由于所有与数据库相关的代码都在重构MyAppWithDatabase
中被移入框架,我只想为框架集成 pod,以保持内部加密机制与主机应用程序的抽象。现在,当我为框架集成时,它开始产生以下构建错误。MyDataPlatform
SQLCipher
函数“sqlite3_key”的隐式声明在 C99 中无效
请注意,此问题是由MyApp
s 源代码的一条语句产生的,作为警告,但 Xcode 构建将其视为错误,
sqlite3_key(_db, [password UTF8String], (int)password.length);
我仍然保留上述行,MyApp
因为将数据库相关代码逐渐移入需要时间,MyDataPlatform
并且我假设 SQLCipher 标头仍然应该在主机应用程序中可用,作为链接中的相关框架。
我在互联网上浏览了许多提出的解决方案,但没有一个适合我的情况。我怀疑大多数解决方案只是关于集成SQLCipher
主机应用程序。在我的情况下,当我收到框架错误时该怎么办?
下面是我的 pod 文件的结构(重构后),
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
workspace 'MyApp.xcworkspace'
target 'MyApp' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
pod 'Google/Analytics'
pod 'GoogleMaps'
# ...
target 'MyAppTests' do
inherit! :search_paths
end
end
target 'MyDataPlatform' do
project 'MyDataPlatform/MyDataPlatform.xcodeproj'
pod 'SQLCipher', '~>3.4.2'
#https://discuss.zetetic.net/t/ios-11-xcode-issue-implicit-declaration-of-function-sqlite3-key-is-invalid-in-c99/2198/53
post_install do | installer |
print "SQLCipher: link Pods/Headers/sqlite3.h"
system "mkdir -p Pods/Headers/Private && ln -s ../../SQLCipher/sqlite3.h Pods/Headers/Private"
end
end
之前SQLCipher
集成在MyAppWithDatabase
ie下
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'MyAppWithDatabase' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
pod 'Google/Analytics'
pod 'GoogleMaps'
pod 'SQLCipher', '~>3.4.2'
# ...
target 'MyAppWithDatabaseTests' do
inherit! :search_paths
end
end
解决方案
SQLITE_HAS_CODEC
在应用程序中定义后,我的问题得到了解决,
MyApp -> Build Settings -> Other C Flags
SQLITE_HAS_CODEC=1
添加应用程序后,另一种解决方案也可以使用,
MyApp -> Build Settings -> Preprocessor Macros
推荐阅读
- apache2.4 - Catalina apache 2.4.41 http://localhost/~username 在此服务器上找不到请求的 URL
- c++ - Shared_ptr 自定义删除器
- java - 收到错误 java.lang.NoSuchFieldError: pBuffers
- c# - 如何将用户分配到 Azure 资源组
- r - 通过R中的属性提取sf对象中的点
- c# - Godot Sentry 崩溃报告
- javascript - 来自 http 409 的 Ajax 解析响应
- ios - 使用 iOS 锁定屏幕上的播放器控件进行远程控制应用程序
- ascii - 如何在 PyCharm 中打印此符号:“█”
- git - 如何使用 git 从提交或拉取请求中提取文件路径和更改?