18

I followed the instruction of Alamofire in github,

I created an xcode project named cocoapods-test & I closed it.

I go to the project folder run pod init command which generates a Podfile. Then I added the following code to the Podfile:

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

pod 'Alamofire', '~> 3.0'

Then, I run command pod install and this is the result in terminal:

Updating local specs repositories

CocoaPods 1.0.0.beta.6 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Downloading dependencies
Installing Alamofire (3.3.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `cocoapods-test.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

Then, in my project folder there is a new file called cocoapods-test.xcworkspace . I double clicked it which opens my xcode again, and I can see the Alamofire module.

Then, I opened my project's ViewController class, and import Alamofire . But no matter how many times I clean & build, I always get error No such module 'Alamofire' . Here is the screenshot:

enter image description here

Why I get this problem though I followed the instruction step by step?

(I am using XCode 7.2.1, Swift 2.1.1 & Alamofire 3.3.0)

======= UPDATE ========

I tried @LK Yeung 's answer, uncomment import Alamofire, then clean & build again, I got a bunch of compiler errors from Alarmofire:

enter image description here

Patrick
  • 1,629
  • 5
  • 23
  • 44
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
  • "You need to add the lib to 'the Link Binary With Libraries' section also." http://stackoverflow.com/questions/25817479/cannot-install-alamofire-in-new-xcode-project-no-such-module-alamofire – YarGnawh Mar 31 '16 at 14:58
  • @YarGnawh , No, the link you provide is a completely different way of installing Alamofire. It downloads the library, but I am using the way Alamofire github suggested, which is through cocoapod tool. They are different. In "the Link Binary With Library", I don't even see Alamofire framework. Because I am installing it in another way, please read my post, I have told step by step how I install it. – Leem.fin Apr 01 '16 at 10:14
  • The instructions at http://stackoverflow.com/a/40360050/1804274 solved my issue – Dudling Nov 01 '16 at 12:37

10 Answers10

17

You need to build the project successfully once before using the library

comment import Alamofire -> build -> uncomment import Alamofire

LK Yeung
  • 3,462
  • 5
  • 26
  • 39
  • 1
    This solved the issue for me. As an aside, it only affects Swift based pods. I was able to successfully import Obj-C based pods without building first. – CodeBender Mar 31 '16 at 20:51
  • Event though I uncomment `import Alamofire`, I clean & build, xcode still build the Alamofire which gives a bunch of compile errors. So, this is not the right answer, because Alamofire is already part of my project. Please see my update – Leem.fin Apr 01 '16 at 10:05
15

Make sure you have opened the "project_name".xcworkspace instead of "project_name".xcodeproj .As you are working on pods all the installed pod will be available only in your .xcworkspace project file.

Saurabh Padwekar
  • 3,888
  • 1
  • 31
  • 37
  • 1
    This was helpful. I'm new to iOS development and after running `pod install` and closing/reopening Xcode, I expected it to pick up the `Alamofire` library. I was running the project in the root directory where both `.xcworkspace` and `.xcodeproj` exist and then `cd` into `.xcworkspace` and opened the project there with Alamofire loading successfully. – Petesta Aug 31 '18 at 23:00
10

I was having this exact same problem. Please make sure that you are on Xcode 7.3 and using Swift 2.2.

You can check your Swift version using xcrun swift -version. Updating Xcode to 7.3 should also automatically update Swift.

Updating Xcode resolved this issue for me.

Anthony To
  • 2,193
  • 2
  • 21
  • 29
4

You need to add the lib to 'the Link Binary With Libraries' section also

Patrick
  • 1,629
  • 5
  • 23
  • 44
2

You can try put pod 'Alamofire', '~> 3.0' like below. And run pod install again.

target 'yourtarget' do
     pod 'Alamofire', '~> 3.0'
end
vien vu
  • 4,277
  • 2
  • 17
  • 30
1

If you're manually installing Alamofire (or any other framework) make sure your build configurations match between both your parent project and the sub project. For example, if your build configuration in your project is called 'Development', but Alamofire's is called 'Debug' you'll get the 'no such module' error.

Justin Domnitz
  • 3,217
  • 27
  • 34
  • This solved it for me when I accidentally deleted the release config on parent project. It was fixed after creating the config back. – Ross Jul 04 '18 at 22:00
1

Follow This Sequence

➼ Open Terminal, go to the project folder and run these commands:

sudo gem install cocoapods -n /usr/local/bin
pod install

➼ Go to this link and clear derive data folder:

~/Library/Developer/Xcode/DerivedData

➼ Then open project "xcworkspace" file and press:

Command + Shift + K 

➼ and then:

Command + B 

It should work now

Cheers!

Haseeb Javed
  • 1,769
  • 17
  • 20
0

I had the same issue, the reason was that I installed the wrong version of alamofire.

I am using Xcode 7.3, swift 2.2, so alamofire 3.0 worked for me

remove the library using these steps mentioned by @Michal

Remove or uninstall library previously added : cocoapods

Then in your pod file

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, ‘9.3’  <-- your target version

use_frameworks!

target ’<your target name>’ do
    pod 'Alamofire', '~> 3.0’

end
0

try to latest updated install alamofire and also check u use alamofire latest is this in your xcode supported.

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

target '<Your Target Name>' do
    pod 'Alamofire', '~> 4.4'
end

try this above alamofire on your podfile

ronak patel
  • 400
  • 5
  • 17
0

No such module 'Alamofire' Error

because you have not installed the Alamofire in your pod file open Podfile and add this line

pod 'Alamofire'

double-check in Podfile if this line already is written then no need to write. then just update pod file

for updating your pod open your Podfile into terminal and dial

pod update
Muhammad Ahmad
  • 388
  • 4
  • 9