0

I recently updated to Xcode 7.0 and am trying to build my project which uses the SQLite.swift library. After converting to the latest swift syntax (Edit->Convert->To Latest Swift Syntax...) I get so many errors and I don't know where to begin fixing them. I also tried to convert the SQLite.swift project separately but always get many warnings at compilation time and some errors like:

/Users/dobrev/Development/iOS/SQLite.swift/SQLite/Statement.swift:25:30: error: cannot invoke initializer for type 'sqlite3_destructor_type' with an argument list of type '(COpaquePointer)'
internal let SQLITE_STATIC = sqlite3_destructor_type(COpaquePointer(bitPattern: 0))
                             ^
/Users/dobrev/Development/iOS/SQLite.swift/SQLite/Statement.swift:26:33: error: cannot invoke initializer for type 'sqlite3_destructor_type' with an argument list of type '(COpaquePointer)'
internal let SQLITE_TRANSIENT = sqlite3_destructor_type(COpaquePointer(bitPattern: -1))

which at the end result in Command failed due to signal: Segmentation fault 11

Can someone help?

maddob
  • 989
  • 1
  • 12
  • 29
  • 2
    There is a branch on GitHub with a version of SQLite.swift for Swift 2 – vadian Sep 18 '15 at 07:20
  • 1
    possible duplicate of [SQLITE\_TRANSIENT undefined in Swift](http://stackoverflow.com/questions/26883131/how-to-use-sqlite-transient-in-swift) – Martin R Sep 18 '15 at 07:46
  • damn, I did not even check the branches of the project - thanks @vadian! – maddob Sep 18 '15 at 08:15

1 Answers1

0
#define SQLITE_STATIC      ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)

from <sqlite3.h> are not imported to Swift, probably due to the "unsafe" pointer casting.

A possible Swift definition is shown in the SQLite.swift project, in Statement.swift:

let SQLITE_STATIC = sqlite3_destructor_type(COpaquePointer(bitPattern: 0))
let SQLITE_TRANSIENT = sqlite3_destructor_type(COpaquePointer(bitPattern: -1))

For Swift 2 you will need

let SQLITE_STATIC = unsafeBitCast(0, sqlite3_destructor_type.self)
let SQLITE_TRANSIENT = unsafeBitCast(-1, sqlite3_destructor_type.self)
Unheilig
  • 16,196
  • 193
  • 68
  • 98
helios
  • 1
  • This issue has beed fixed for a very long time on the main branch of SQLite.swift. I guess there will be similar issues when Swift 3.0 is released – maddob May 09 '16 at 12:54