Search code examples
objective-cswiftfmdb

FMDatabaseAdditions methods not accessible in swift?


I am porting some existing code over to swift. I am using FMDB in swift and everything has been good so far, but I do not have access to FMDatabaseAdditions methods in my project in spite of having access to everything else (FMResultSet, FMDatabasePool and so on).

  1. I have the bridging-header file with the #import "FMDB" statement and it has the includes for all the other FMDB files.
  2. I have looked in my build phases and I can see FMDatabaseAdditions.m in the "Compile Sources" and I have moved it to the top of the list.

Still xCode doesn't recognise it or its methods.

Any ideas?


Solution

  • UPDATE: Head over to the link below (in bold) for an unofficial FMDatabaseAdditionsVariadic.swift file as provided by Robert. Also keep an eye out on the repo for when the fix is officially added in.

    Thanks again Rob!

    -- ORIGINAL MESSAGE --

    I found out what is going on from the guys on github over at FMDB repo.. (see original post here):

    I notice that some of the FMDatabaseAdditions methods work fine. For example:

    if db.tableExists("test") {
        println("test table exists")
    } else {
        println("test table doesn't exist")
    }
    

    It looks like Swift is having issues with the variadic methods within the category. This is a known problem with Swift, but while I created the variadic rendition of executeQuery and executeUpdate, I didn't do so for the FMDatabaseAdditions methods. I will take care of this. Thanks for bringing it to our attention.

    Thanks robertmryan for your help.