markhorrocks markhorrocks - 1 year ago 92
iOS Question

var request: Alamofire.Request? Use of undeclared type Alamofire

I'm converting my swift 2.2 code to swift3 code in Xcode 8 and I have this line:

var request: Alamofire.Request?

which is producing this error:

Use of undeclared type Alamofire.

How can I fix this error? I have read the migration guide but I don't see anything which helps me. I am using Alamofire 4.0.1

Answer Source

The code itself is ok. The issue is most probably with importing Alamofire module

Try the following steps:

  1. import Alamofire in the swift file where you need to use Alamofire module (and @import Alamofire in bridging header if needed)
  2. Clean (Cmd + Shift + K)
  3. Build the project

If you see No such module error, you should run pod install command from Terminal and open the generated workspace instead of the project itself.