Failed to import Alamofire

I try to import Alamofire inside my class, but I get the Cannot load underlying module for 'Alamofire' error message. I followed the same steps by importing another library (SwiftyJSON) and it worked. This is my sub-file:

 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 import Alamofire in my class, it is not found (but SwiftyJSON is).

What am I doing wrong?

+7
source share
5 answers

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

Possible fixes mentioned here:

  • Product β†’ Cleaning
  • Restart xcode
+13
source

Anyone who has this problem could forget one step.

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

Project> Purpose> General> Related Structures and Libraries:

enter image description here

+5
source

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

 platform :ios, '10.0' 

and I create a project using 8.0

After restoring my project with the specified version of the module in my project, the error disappeared.

+1
source

Check the Alamofire documentation and see if the requested xcode version is the same as yours.

0
source

Use the .xcworkspace of your project after installing the modules.

0
source

All Articles