Alamofire No Such Module (CocoaPods)

我是研究僧i 提交于 2019-12-30 02:36:15

问题


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

TERMINAL

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


回答1:


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'



回答2:


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




回答3:


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



回答4:


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:


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.




回答6:


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



回答7:


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.




回答8:


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




回答9:


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




回答10:


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




回答11:


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




回答12:


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.




回答13:


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



回答14:


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



回答15:


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.



来源:https://stackoverflow.com/questions/32466073/alamofire-no-such-module-cocoapods

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