I have looked at all the other posts with the same error (use of undeclared type) but still can’t figure out what is wrong with my project.
The difference with the other cases is that I can successfully use the FMDatabase in AppDelegate and ViewController classes but not from another class I've created, though in the same project as the AppDelegate and ViewController classes.
And by "successfully use", I mean I can access the database and tables in it.
Also note that I didn’t have to import anything to use FMDatabase in AppDelegate or ViewController.
So far what I have done (Xcode. 6.4 Swift 1.2):
Created a single view swift project.
Installed FMDB using cocoapods (https://cocoapods.org/?q=fmdb)
Created a bridging header for FMDB
I can successfully declare and use FMDatabase from the AppDelegate.swift and ViewController.swift classes.
AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var database: FMDatabase? // OK
...
ViewController.swift
class ViewController: UIViewController {
var database: FMDatabase? // OK
...
In DBUtil.swift though I’m getting the “Use of undeclared type ‘FMDatabase’” error.
DBUtil.swift
class DBUtil {
var database: FMDatabase? // Error: "Use of undeclared type 'FMDatabase'
}
A reproducer is available at Swift Bridging Header.
For any hints or ideas, thank you in advance.