Anuj Arora
Anuj Arora

Reputation: 3047

Alamofire No Such Module (CocoaPods)

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

Upvotes: 38

Views: 62977

Answers (20)

Nike Kov
Nike Kov

Reputation: 13698

In my case the problem was because of Module Verifier setting. Switched it off. https://developer.apple.com/documentation/xcode/identifying-and-addressing-framework-module-issues

The error sounded like: (fatal) could not build module 'Test'

Upvotes: 0

Gizem Turker
Gizem Turker

Reputation: 254

You can start by making sure you open the Xcode workspace file (with the extension .xcodeproj) instead of the project file (with the extension .xcworkspace). The workspace file contains dependencies installed by CocoaPods, and it is necessary to use it to work on your project.

Upvotes: 0

Vladimir Sukanica
Vladimir Sukanica

Reputation: 575

For me, solution was to exclude arm64 devices from Pods and Project. Image is in attachment.

Problem solved

Upvotes: 1

Roman
Roman

Reputation: 250

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.

Upvotes: 0

Jay Shenawy
Jay Shenawy

Reputation: 1033

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

Upvotes: 5

tony Macias
tony Macias

Reputation: 226

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.

Upvotes: 1

Iman Rosstin
Iman Rosstin

Reputation: 2345

[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.

Upvotes: 0

Ousseynou NDIOUR
Ousseynou NDIOUR

Reputation: 51

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

Upvotes: 5

Eric Mentele
Eric Mentele

Reputation: 1050

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

Alamo Fire Link Binary With Libraries

Upvotes: 3

J A S K I E R
J A S K I E R

Reputation: 2184

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).

Upvotes: 0

DoruChidean
DoruChidean

Reputation: 8138

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.

Upvotes: 0

Harish Pathak
Harish Pathak

Reputation: 1607

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

Upvotes: 0

ewizard
ewizard

Reputation: 2862

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

Upvotes: 1

sahiljain
sahiljain

Reputation: 2374

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.

Upvotes: 3

Zeeshan
Zeeshan

Reputation: 4244

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

Upvotes: 3

albogdano
albogdano

Reputation: 2840

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.

Upvotes: 5

Dimitri T
Dimitri T

Reputation: 951

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).

Upvotes: 10

danroose
danroose

Reputation: 855

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

Upvotes: 78

satoshin
satoshin

Reputation: 309

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

Upvotes: 29

Suraj
Suraj

Reputation: 145

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'

Upvotes: 9

Related Questions