how to correctly add sqlite frameworks to the Xcod

2019-07-09 12:01发布

I am trying to add SQLite to my project.I checked the target dependencies under the build phase tab,it is empty, which is true.I am getting the following error:Unable to run command 'Ld SQLite' - this target might include its own product."

I am using swift 3. Can you please help me? Thanks in advance

2条回答
冷血范
2楼-- · 2019-07-09 12:09

I'm not in front of a Mac at present, but I think all you need to do under Build Phases is go to Link Binaries with Libraries, hit the add button and type in "sqlite" so you can select libsqlite3.

查看更多
够拽才男人
3楼-- · 2019-07-09 12:27

Xcode 9 and Swift 3.2 (or, obviously Swift 4), just import SQLite3 in your relevant Swift file ...

import SQLite3

... and it will import the library for you.

In older Xcode versions (or if you turned off automatic library/framework linking), you have to manually link to the libsqlite3 library in the target settings under the “Build Phases”:

enter image description here

But in Xcode 9 with the default settings, all you need is that import line.

查看更多
登录 后发表回答