34
votes

Using Xcode 7

I am trying to install Alamofire in a sample project. Have used the instructions from Ray Wenderlich's page

Only change from above link is the podfile -- which is from GitHub page here because the version has been updated. I have also used the Swift 2.0 branch.

Below is the snapshop of the error, my pod file and my terminal post installing the pod

PODFILE enter image description here

TERMINAL enter image description here

P.S: I want to use cocoapods to install Alamofire. I don't want to download it from github page

17
When you hit pod install, do you get Alamofire downloaded? - Shamas S
I think so..I have added the screenshot of my terminal in the original question..pls have a look - Anuj Arora
how did you solve this? - user2526811

17 Answers

9
votes

Try this one.

For Swift 2.0 there is no need to add Alamofire.xcodeproj into your xcode. Simply copy and paste source folder from https://github.com/Alamofire and you are done.

or if you want to install Alamofire from Cocoapods then try below code.

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

  pod 'Alamofire', '~> 2.0'
67
votes

The Trick for me was to open the .xcworkspace file rather then the original project file itself.

28
votes

working this:

Scheme -> Manage Schemes...

checked Alamofire checkbox → Build Alamofire scheme

and, if you used Playground , you should change settings Playground:

View -> Utilities -> Show File Inspector 

Platform OSX → iOS
9
votes

import Alamofire after importing UIKit Then comment it out, build the project first. Uncomment it. (this worked for me, and others, when the other answers did not).

5
votes

For reference to anyone who comes across this problem in the future:

Swift 2.x + CocoaPods 1.x

Symptoms: build works in Xcode for debug configuration but fails when xcodebuild is executed from console using pod lib lint or similar command. The result is error: no such module 'X'

Solution: In MyProject.podspec add your dependencies without specifying versions:

spec.dependency "Alamofire"

The Podfile should also contain the same dependencies. Then run:

$ pod install && open MyProject.xcworkspace

You should open .xcworkspace instead of .xcodeproj. The build will now work in both Xcode and console and pod lib lint passes validation.

I wrote this because I was trying to publish a new CocoaPods pod library and had a similar issue but found no answer and also because Google leads to this question.

5
votes

Here is what to do:

  • close your project,
  • install your pod library,
  • then install alamofire.

After you do all things, don't open the file with extension .xcodeproj but open the file with extension .xcworkspace

3
votes

My problem was solved using these steps :

Clean Project Goto Project > Build Setting > Framework Search Path and add

  • "$PODS_CONFIGURATION_BUILD_DIR/Alamofire" as non-recursive
  • $(inherited) as non-recursive
  • $(SRCROOT) as recursive
2
votes

Have been facing the same problem, following trick resolved the issue

Go to Manage scheme -> Select pod library that is causing issue -> Build

Change back the scheme to project and then run the app, you are good to go

Note: If you don't see the pod library in the scheme, go to Manage scheme and select the pod library that you would like to build.

2
votes

Adding Alamo Fire to all of my target's build phases fixed it for me.

Alamo Fire Link Binary With Libraries

2
votes

There is only one way to solve this issue.

Quit Xcode.

Delete project's temp files located at /Users/username/Library/Developer/Xcode/DerivedData

Delete ProjectName.xcworkspace

Delete Podfile.lock file and Pods folder Run pod install.

Open the newly created ProjectName.xcworkspace file and build.

credits to Dimitris Bouzikas here

1
votes

After doing @satoshin answer, I also had to check the Shared box on the right hand side of the Manage Schemes window.

1
votes

go to finder locate the project and navigate to the '.xcworkspace' file. thats where your pods are installed. if you go to your original project '.xcodeproj' you will only the pod debug files. hopes this helps. took me a while to figure out the problem too.

0
votes

I am using swift 3, I fixed this problem by deleting Derived Data for this project. Cheers...!!!

0
votes

If clean project/restart xcode/reinstall cocoapods etc, did not work. You can try running Product -> Build for -> Testing (cmd + shift + u). The build failed but the import worked right after.

0
votes

As for me worked to change the name of the project. Accidentally put

ProjectNameTests

instead of

ProjectName

No schemas needed if you've configured the names correctly everywhere:

  1. Check Podfile
  2. Check which project file you've launched. (The white icon should be created for "xcworkspace")
  3. Product -> Clean Build Folder
  4. Product -> Build (Now you can run in a simulator).
  5. Start from the scratch, because most of the errors always occur in a cause of humanity mistake, not developers.
  6. If you've put the wrong name for project in Podfile check "Linked Frameworks...". If so - delete this framework. The path is showed below at screenshot.enter image description here

Example of correct Podfile (Alamofire):

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

target 'ProjectName' do
  pod 'Alamofire', '~> 4.7'
end
  • ProjectName should not contain any extensions(file types).
0
votes

[For future seekers] you could have missed the second step from the below :

Go to Project Setting

  1. Go to Build Phase tab, create a new run script phase and add an input file to your Alamofire framework. In my case I set $(SRCROOT)/Carthage/Build/IOS/Alamofire.framework
  2. Go to General tab, scroll down to linked framework and libraries add Alamofire.Framework folder. You probably won't find it from list so you need to press "Add Other" button and introduce it yourself.
0
votes

For absolute newbie just close xcode project and open by the new way. Choose in your folder file which contains extension like this: .xcodeproj and just enjoy you life.