Reputation: 20138
I am trying to make the sqlite library work in my Swift project in xCode 6.3.
When I try to use it in code I get the following error:
I have added the library in my project like so:
And I have imported it in the bridging header like this:
The sqlite function calls do autocomplete so it seems like it is added properly, but it still gives me the error of undefined symbols...
Any idea what I am doing wrong?
Thank you
Upvotes: 0
Views: 2115
Reputation: 20138
So I was able to use sqlite3.dylib in a Swift project by doing the following:
I created the bridging header. I created a wrapper objective-c class.
In the bridging header I then imported both and my custom wrapper header.
Because in my bridging header I imported my custom sqlite wrapper now my swift code can access the methods I exposed in its header.
So, the point is that my objective-c wrapper can access the sqlite3.dylib, and because I import the wrapper class in the bridging header my Swift code can then use it.
So, Swift cannot access the sqlite3.dylib c code directly, but my objective-c code can, which works as the "middle guy" between sqlite3.dylib and Swift code.
Upvotes: 1
Reputation: 972
If you want database connection in swift then use sqlite.swift library it is easier than sqlite3.dylb here is procedure how to use it click Here
Upvotes: 1