ios - 在 Playgrounds 中使用 Alamofire 无法查找符号错误
问题描述
我正在使用 Playgrounds,并通过 Podfile 安装了 Alamofire 和 SwiftSoup。我可以使用 Alamofire 从 URL 中检索 HTML,URLSession
但希望这样做。我的代码如下。
let url = "https://www.nba.com/warriors/stats"
Alamofire.request(url, method: .post, parameters: nil, encoding: URLEncoding.default).validate(contentType: ["application/x-www-form-urlencoded"]).response { (response) in
if let data = response.data, let _ = String(data: data, encoding: .utf8) {
do {
print(data)
}
}
}
我不确定为什么会收到以下错误。
error: Couldn't lookup symbols:
Alamofire.DataRequest.response(queue: Swift.Optional<__C.OS_dispatch_queue>, completionHandler: (Alamofire.DefaultDataResponse) -> ()) -> Self
protocol witness table for Alamofire.URLEncoding : Alamofire.ParameterEncoding in Alamofire
type metadata accessor for Alamofire.DataRequest
Alamofire.DataRequest.validate<A where A: Swift.Sequence, A.Element == Swift.String>(contentType: A) -> Self
Alamofire.request(_: Alamofire.URLConvertible, method: Alamofire.HTTPMethod, parameters: Swift.Optional<Swift.Dictionary<Swift.String, Any>>, encoding: Alamofire.ParameterEncoding, headers: Swift.Optional<Swift.Dictionary<Swift.String, Swift.String>>) -> Alamofire.DataRequest
protocol witness table for Swift.String : Alamofire.URLConvertible in Alamofire
static Alamofire.URLEncoding.default.getter : Alamofire.URLEncoding
type metadata for Alamofire.URLEncoding
解决方案
尝试将此添加到您的Podfile
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CONFIGURATION_BUILD_DIR'] = '$PODS_CONFIGURATION_BUILD_DIR'
end
end
end
确保再次运行 pod install 以重新生成 Pods 项目。然后用 清理构建,用Command-Shift-K
重建它Command-B
,然后运行你的 Playground。错误应该消失。
推荐阅读
- c# - 实时数据的 C# websocket 流控制
- python - 使用 @property 装饰器和 dunder 方法
- powerbi - Power bi 工作流数据仓库设计
- esp8266 - 使用 nodemcu esp8266 将多变量发送到 ubidots?
- python - python:访问装饰函数的返回值
- r - 基于R中的公共列连接两个数据框
- java - 通过加入表格的优先级来提高性能
- swift - 基于链接对象的 Realm Studio 语法过滤结果列表
- c++ - 编写一个程序,读取两组整数元素(每组 10 个元素)并找到两组的交集
- redux-observable - 在 redux-observable 中链接史诗是一种糟糕的模式吗?