ios 模块“Alamofire”没有名为“request”的成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28549832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 04:51:06  来源:igfitidea点击:

Module 'Alamofire' has no member named 'request'

iosalamofire

提问by user3579107

I'm new to iOS Development, I installed Alamofire as said in README, but I have this error as other users and I don't know how to solve it.

我是 iOS 开发的新手,我按照 README 中的说明安装了 Alamofire,但是我作为其他用户遇到了这个错误,我不知道如何解决。

a busy cat

一只忙碌的猫

采纳答案by ton-katsu

Alamofire.xcodeproj -> Build Phases -> Complie Sources

Alamofire.xcodeproj -> Build Phases -> Complie Sources

If (0 item), then "[+]Alamofire.swift".

如果(0 item),则“ [+] Alamofire.swift”。

It's OK :)

没关系 :)

回答by Said-Abdulla Atkaev

2019 UPDATE

2019年更新

If you have this error and you use 'alamofire5' branch just change Alamofire.requestto AF.request.

如果您遇到此错误并且您使用 'alamofire5' 分支,只需更改Alamofire.requestAF.request.

回答by Sultan Ali

if you are using new Alamofire 5.xxxthen you will use AFinstead of Almofireit like that

如果您使用的是 newAlamofire 5.xxx那么您将使用它AF而不是Almofire那样

AF.upload(multipartFormData: <#T##(MultipartFormData) -> Void#>, to: <#T##URLConvertible#>)

AF.request(<#T##url: URLConvertible##URLConvertible#>)

AF.download(<#T##url: URLConvertible##URLConvertible#>)

回答by Yuxuan Chen

I solved this issue by changing the Build Active Architectures Only settings.

我通过更改 Build Active Architectures Only 设置解决了这个问题。

Click on your project in the Project Explorer, select Build Settings, locate Architectures section, and change the Build Active Architecture Only setting to Yes for Debug and No for Release.

在 Project Explorer 中单击您的项目,选择 Build Settings,找到 Architectures 部分,并将 Build Active Architecture Only 设置更改为 Yes(调试)和 No(发布)。

Hope this will work for you.

希望这对你有用。

回答by uplearnedu.com

I found this answer and it worked for me:

我找到了这个答案,它对我有用:

I had the same problem after installing from cocoapods. Choosing Product | Clean then Product | Build fixed it. enter image description hereI selected my project name then the project then. - Clean Cmd+shit+K - Build Cmd+B Strangely enough this worked for me. Good Luck!

从 cocoapods 安装后我遇到了同样的问题。选择产品 | 清洁产品 | 构建修复它。 enter image description here我选择了我的项目名称,然后选择了项目。- Clean Cmd+shit+K - Build Cmd+B 奇怪的是这对我有用。祝你好运!

回答by cnoon

Without having the actual project, it is very difficult to tell what the problem is. However, you do have a problem with the code that you have written. This won't compile with the data/string/JSONvariable being declared. That "may" be the actual problem. Please try the following and see if that helps.

没有实际项目,很难判断问题出在哪里。但是,您编写的代码确实存在问题。这不会与data/string/JSON声明的变量一起编译。那“可能”才是真正的问题。请尝试以下操作,看看是否有帮助。

Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["foo": "bar"])
         .response { request, response, data, error in
             println(request)
             println(response)
             println(data)
             println(error)
         }