Search code examples
sqlite.swiftxcode10.1xcode11.4

SQLite.swift: Can't retrieve table count due unrecognized token: ":" (code: 1)


My current code is written with Swift 3 ,I tried to change Swift 4.2 via Xcode10.1. SQLite is crashing on changes version and working correct on old code.

I'm trying to retrieve a count of records in a table using SQLite.swift and Swift in a Cocoa macOS application.

let db = try Connection("\(pathh)/db.sqlite3")
let users = Table("users")
var count = try db.scalar(users.filter(userid == userid).count) 

However, when this code is executed (from a button click event handler), the following exception is thrown:

unrecognized token: ":" (code: 1)

When I tried to use var count = try db.scalar("SELECT COUNT(*) FROM users WHERE userid=?",userid) as! Int64 , the correct result is returned.

Any and all help would be appreciated. Thanks in advance!


Solution

  • In my project,I required updating was the following in my Podfile:

    pod 'SQLCipher', '~>4.2.0' pod 'SQLite.swift/SQLChiper', '~>0.12.0' After pod update unrecognized token: ":" (code: 1) is solved.