gpt4 book ai didi

swift - 在 Swift 中为 macOS 构建框架时出错

转载 作者:行者123 更新时间:2023-11-28 06:23:34 25 4
gpt4 key购买 nike

我已经用 Swift 为 SQLite3 编写了一个包装器,它运行良好。

我想到了做一个框架。

问题是:

要在 swift 中使用 SQLite3,我们应该使用桥接 header 导入 sqlite3.h。但是我在框架项目中没有桥接头的选项。

我创建了一个 .c.h 并在 .h 中导入了 sqlite3.h 并制作了.h 公共(public) header 。但它不起作用。它仍然给出 use of unresolved identifier 错误。

如何将 .c.cpp 文件导入到 swift 框架项目中?

谢谢!

最佳答案

我认为您只能使用项目中的头文件(如果我错了,请纠正我)。因此,将 sqlite3.h 添加到您的项目中。

第 1 步:

搜索sqlit3.h

Xcode.app(右击)->显示包内容

enter image description here

第 2 步:

在你的 Xcode.app 中搜索 sqlite.h

enter image description here

第 3 步:

将该文件拖到您的 xcode 项目中并选择 copy items if needed

enter image description here

第 4 步:

从导航器中选择 sqlite3.h 并在右侧面板中将其更改为 Public

enter image description here

第 5 步:

在 Xcode 为您创建的头文件中导入 sqlite3.h。您应该将其导入为 #import "sqlite3.h"

enter image description here

第 6 步:

现在构建项目。它应该可以正常工作。

关于swift - 在 Swift 中为 macOS 构建框架时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42647597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com