SwiftyJSON - var searchIndex: Index! Error

Every time I import SwiftyJSON into my project. I throws an error with Index! Does anyone know how to fix this?

class SearchVC: UITableViewController {
    
    
    
    var businessSearch = [Business]()
    
    var businessIndex: Index!
    let query = Query()
    var searchId = 0
    var displayedSearchId = -1
    var loadedPage: UInt = 0
    var nbPages: UInt = 0

Indeed, importing SwiftyJSON in the same file as Algolia leads to the following compile-time error:

error: reference to generic type 'Index' requires arguments in <...>
    var businessIndex: Index!
                       ^
                            <Any>

This is because SwiftyJSON also defines an Index type. The solution is to disambiguate the type by prefixing it with the module name:

var businessIndex: AlgoliaSearch.Index!
1 Like