Swift 2.0导入并使用sqlite3库进行编译 [英] Swift 2.0 import and compile with sqlite3 library

查看:143
本文介绍了Swift 2.0导入并使用sqlite3库进行编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Swift 2测试某些sqlite,但是在带有库的Link Binary中添加libsqlite3.0.tbd文件时,我无法进行正确的构建.我也尝试从/usr/lib添加libsqlite3.dylib,但出现以下错误.

Trying to test some sqlite with Swift 2 but I cannot make a correct build when adding the libsqlite3.0.tbd file on the Link Binary with libraries. I also tried to add the libsqlite3.dylib from /usr/lib but I get the following error.

ld:找不到用于-lsqlite3的库 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

ld: library not found for -lsqlite3 clang: error: linker command failed with exit code 1 (use -v to see invocation)

有关如何正确使用库进行构建的任何想法.这只是一个空项目,仅用于测试.提前谢谢.

any idea on how can I correctly build with the library. It is just an empty project just for testing. Thanks a lot in advance.

推荐答案

同时,您可以使用以前的SDK中的libsqlite3.dylib.打开终端,输入

Meanwhile, you can use libsqlite3.dylib from previous SDK. open terminal, type

locate libsqlite3.dylib

您会找到类似以下的文件:

You'll find several files like these:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libsqlite3.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libsqlite3.dylib

转到项目的设置->构建阶段->与二进制文件链接.通过依次单击+Add Other来添加两个文件.点击Cmd-Shift-G,然后复制粘贴文件路径.点击Open.

Go to your project's setting -> Build Phases -> Link with Binaries. Add BOTH files by clicking +, then Add Other. Hit Cmd-Shift-G, and copy-paste the file path. Click Open.

如果使用macports安装sqlite3,请从构建设置"中的库搜索路径"中删除"/opt/local/lib".

If you install sqlite3 using macports, remove /opt/local/lib from Library Search Path in Build Settings.

这篇关于Swift 2.0导入并使用sqlite3库进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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