Importing Alamofire 3.4 - No such module 'Alamofire'

一世执手 提交于 2019-12-07 13:17:06

问题


I hava a project that need Alamofire imported and every aproach i took got me to same porblem import Alamofire - No such module 'Alamofire'

  • Installed cocoapods
  • Edited Podfile:

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

platform :ios, '9.0'

use_frameworks!

target 'my project name' do

    pod 'Alamofire', '~> 3.4'

end

$ pod install

everything was smooth and had no errors in the proces from installing cocoapods to the end.

Opened project with projectname.xcworkspace

Even tried the manually and still the same problem - No such module 'Alamofire'

Thank you for the help in advance.


回答1:


Do import Alamofire and then do Build. I think it's helpful.




回答2:


After adding a framework through CocoaPods, in most conditions you are supposed to clean and build the project right away.

That should take care of adding/building the new framework to your app and make it active for use

Also, please note that another copy of your project will be created upon addition with pods, called something like 'yourProjectName.xcworkspace' (You can find it in your directory). It will have a light blue color thumbnail. After adding your pods, you must start using that copy of your project instead of the normal project.

// Note : Generally with CocoaPods, when you add a pod to your Podfile, you just need to save the Podfile and type 'podinstall' in your terminal. Make sure to get to your project directory before that. That will import the frameworks automatically. However, you do need to write import statement in your file to use it obviously

You do not need to import Alamofire framework explicitly (if using Cocoa Pods) - Umair (in comments)




回答3:


I had a similar issue and solved it following the below listed steps:

  1. Realized that <projectName>.xcworkspace is what you need to be using after adding a pod to your project
  2. Deleted the pods folder and Podfile.lock and did a pod install
  3. Set Architectures to Standard architectures (armv7, armv7s, arm64)
  4. Set Build Active Architectures Only to Yes



回答4:


I Faced the Same Issue During the Implementation

Step 1 :

Import Alamofire

Step 2 :

Keep on Pressing Build ( Cmd + B )

Step 3:

If Issue Continues then just close your program for a moment by completely closing it(cmd + Q) and then Restart it and Follow Step 1 & 2

This will work

Thanks




回答5:


If you install dependencies using Pods, and if you are working using .xcodeproj file, it will never build prompting no such module error. You should definetely switch to .xcworkspace and you will see everything's fine. If the error persists, you should clean the project or delete derived data.



来源:https://stackoverflow.com/questions/37743680/importing-alamofire-3-4-no-such-module-alamofire

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