Giorgio Antonioli
Giorgio Antonioli

Reputation: 16224

Can't import Alamofire

I'm trying to import Alamofire inside my class but I obtain the error message Cannot load underlying module for 'Alamofire' . I did the same steps importing another library (SwiftyJSON), and it worked well. This is my podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
    pod 'SwiftyJSON', '~> 2.2.0'
    pod 'Alamofire', '~> 1.2'
end

target 'MyAppTests' do
    pod 'SwiftyJSON', '~> 2.2.0'
    pod 'Alamofire', '~> 1.2'
end

Then I use $ pod install and I can find Alamofire as a module under Pods.

When I put in my class import Alamofire, it isn't found (but SwiftyJSON is).

What I'm doing wrong?

Upvotes: 8

Views: 16536

Answers (4)

crubio
crubio

Reputation: 6422

Anyone else having this issue could have forgot one step.

You may need to link Alamofire (or SwiftyJSON) to your project.

Project > Target > General > Linked Frameworks and Libraries:

enter image description here

Upvotes: 5

Naveed Ahmad
Naveed Ahmad

Reputation: 6747

In my case, my ios version was different, in pod file

platform :ios, '10.0'

and I build the project using 8.0

After rebuilding my project with the pod specified version in my project, the error has gone away.

Upvotes: 1

shivamkaushik
shivamkaushik

Reputation: 374

Check the Alamofire documention and see if the requred xcode version is same as yours.

Upvotes: 0

tilo
tilo

Reputation: 14169

This issue was already reported on Github: https://github.com/Alamofire/Alamofire/issues/441

Possible fixes mentioned there:

  • Product -> Clean
  • Restart Xcode

Upvotes: 13

Related Questions