Alamofire No Such Module (CocoaPods)

喜你入骨 提交于 2019-11-30 08:02:52

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'

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

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

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

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.

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

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.

Ousseynou NDIOUR

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

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

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

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

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.

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.

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!