在框架中使用sqlite [英] Using sqlite in framework

查看:37
本文介绍了在框架中使用sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在快速创建一个框架,我需要使用 sqlite.

I am creating a framework in swift and I need to use sqlite.

我已经导入了 #import <sqlite3.h> 来使用它,我将它写在由 Xcode 创建的 .h 文件中.

I've imported #import <sqlite3.h> to use it and I am writing it in .h file created by Xcode.

但是在构建时,我收到此错误:

But while building, I am getting this error:

在框架模块中包含非模块化头文件".

我已经搜索了这个问题,但找不到解决我问题的合适答案.

I have searched for this question but couldn't find an appropriate answer that solves my problem.

推荐答案

要在自定义框架中使用 SQLite,您需要将 sqlite3.h 文件直接包含到项目中,然后将该文件设为公开.

To use SQLite in a custom framework, you need to include the sqlite3.h file directly into the project and then make that file public.

  • 要获取 .h 文件,请右键单击 Xcode 并选择显示包内容"
  • 在搜索栏中,输入sqlite3.h"
  • 在搜索区域中选择 Xcode

  • 将文件拖到您的项目中,然后选择如果需要,复制项目"
  • 在项目导航器中选择 sqlite3.h 文件
  • 在实用程序窗格中,将目标成员资格更改为公开.

在你的伞头文件中,确保添加这一行:

In your umbrella header file, make sure you add this line:

#include "sqlite3.h"

(不要使用 <sqlite3.h> 表单,因为您现在要包含项目中的文件)

(Don't use the <sqlite3.h> form as you're now including the file from your project)

您可能会注意到,伞头会自动添加一行 #import ,如下所示.如果您不需要 UIKit,则删除该行.

You may notice that the umbrella header automatically adds the line #import <UIKit/UIKIt.h> as shown below. If you don't need UIKit, then remove that line.

您可以在此处找到完整示例:https://github.com/AaronBratcher/ALBNoSQLDB

You can find a full example here: https://github.com/AaronBratcher/ALBNoSQLDB

这篇关于在框架中使用sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆