Kodeco Forums

SQLite Tutorial: Getting Started

In this SQLite tutorial, you'll learn how to interact with the SQLite C APIs directly from Swift, before moving on to create you're own SQLite Swift wrapper.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1321-sqlite-tutorial-getting-started

Very good tutorial. I specially enjoyed the second part where we had to write a Swift wrapper for a C API. That knowledge will come handy elsewhere too.

I just installed OS X 11.4 and Xcode 7.3 and everything stopped working.

That’s a pity. As an old SQL programmer I’ve had a lot of joy with going through this tutorial, with the last version og OS X and Xcode. I still has something left. Hope you can update the project and/or text!

Hi,

Are the uploaded project files correct? For example:

  • The starter project file doesn’t contain any playground but, the tutorial seems to suggest it does.
  • The final project is the same as the starter project.

Please advise.

Thank you,
MA

I just verified that the tutorial works fine with Xcode 7.3 and Swift 2.2, please be sure that you are opening the SQLiteTutorial.xcworkspace file NOT SQLiteTutorial.xcodeproj

Sorry, my mistake. Completely missed that part.
Thank you,
Mukund

I have just started this tutorial only to receive an error not allowing any more progress. If you could respond ASAP that would be amazing. When I open the “Tutorial.playground”, I receive a “Command failed due to signal: Segmentation fault: 11” error. This is even without any code being put into the project. I have tried to build and clean multiple times with no help. Anything is appreciated.

-Ben

Are you on Xcode 7.3 and opening the .xcworkspace? Don’t open just the playground file by itself.

Turns out I was using 7.3.1, This tutorial might break with that update. works in 7.3 now, thank you. Might want to take a look at it in 7.3.1 though. Thank you very much

:scream_cat: I’ll run through 7.3.1 and see what I get

Hi Chris, what about Xcode 8 and Swift 3 compatibility? At the moment is not working. Thanks for the great tutorial. Best

This definitely will not work with Swift 3, it will need to be updated for that. You might be able to run it under Swift 2.3 in Xcode 8 however.

Can we do it without using C API & workspace ?

Hi Chris i am currently in the “making it Swift” Part
In the database connection section nothing is print in the right panel when i run it
it should print “Successfully opened connection to database.”
i have even copy paste your code to try it and it didn’t work
Can you help me ASAP or if someone else know why please tell me, thank you

Mathias

Hi, I am trying to use bind variables in update statement but its giving null value. can anyone help?

Chris,
There seems to be something missing in your tutorial on how to get past the

( quoting the text )
"error message on the line import SQLite. You’ll need to build the project at least once by pressing Command + B;
( /quote )

The Playground compiler seems to be suggesting it’s missing the C Bridging Header.
I’m using XCode Version 7.3.1 (7D1014) for this one, If i download a legacy 7.3.0 and use that instead will that make a difference?
thanks
~rob v

Sadly I had updated to XCode 8 before I found this, so haven’t got it to run, as it needed to convert it to swift 2.3 (minimum). My knowledge of swift is about an hour, but I have managed to get the Playground.swift file to build, but now I have ‘No such module ‘SQLite’’. Any idea where in a swift project I would look for that?

I just updated the first part “The C API” to Swift 3 and up until now everything seems to be working. Here’s the link: Updating SQLite Tutorial code to Swift 3. See the tutorial at: https://www.raywenderlich.com/123579/sqlite-tutorial-swift · GitHub

I hope to update the rest of it tomorrow. :wink:

Just updated the gist with the rest of the code. Enjoy! :wink:

I’m not that good with Xcode yet but was interested in working though the SQL Lite tutorial. I saw that you made some Gist’s to get it working with Xcode 8 / Swift 3 but i have no idea what to do with the two files. I don’t see files with those names in the project folder.

Any help?

Trevis