3

我正在尝试构建一个使用 sqlite 的命令行工具。我已经下载了Stephen Celis 的 swift 包装器 SQLite.swift,并构建了一个可以运行的 OS X 应用程序。但是,我无法构建我的命令行工具。我相信我正确地遵循了SQLite.swift Documentation for frameworkless targets中的说明,但显然我遗漏了一些东西。我在 Helper.swift @ import CSQLite -> No such module 'CSQLite' 中遇到错误。

  • 我正在链接 libsqlite3.dylib(也尝试过 libsqlite3.tbd)
  • 我将 SQLite.swift 源添加到我的项目中
  • 我将#import sqlite3.h & #import "SQLite-Bridging.h" 添加到我的桥接头文件中。也许值得注意的是,当我右键单击 sqlite3.h 或 SQLite-Bridging.h 时,xCode 不知道它们在哪里/是什么。

我很高兴将我的测试项目(大约 80KB,压缩)发送给任何能够并愿意提供帮助的人。可能有一个非常简单的解决方案,我只是不明白它是什么。

谢谢任何帮助,

-克雷格

4

1 回答 1

5

我遇到了同样的问题。有很多编译器错误,例如“Connection.swift:26:8: Could not build Objective-C module 'CSQLite'”

该错误源于“lctx.h:13:25: Use of undeclared identifier 'SYS_getlcid'”

值得一提的是,我安装了两个 Xcode - /Applications 的 v 6.2 和 ~/Applications 的 v 7.3。我的项目是带有 SQLite pod 的 Swift 上的 iOS 应用程序,我使用 Xcode 7.3 打开它。

SQLite pod 在 project_folder/Pods/SQLite.swift/CocoaPods/iphonesimulator/module.modulemap 中有一个文件。该文件有内容

module CSQLite [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" export * }

为了修复编译器错误,我将 module.modulemap 的内容更改为

module CSQLite [system] { header "/Users/my_user_name/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" export * }

变化是我将 sqlite3.h 的搜索指向 Xcode 7.3 所在的 ~/Applications 文件夹。这使我的项目编译。

于 2016-04-28T13:02:55.323 回答