【发布时间】:2018-10-10 12:52:58
【问题描述】:
我正在尝试在使用 Swift 4 编码的项目中使用 AlamofireImage。pod 安装运行良好,但是当我导入模块时出现错误“无法构建 Objective-c 模块 AlamofireImage”
我还注意到一堆关于 AlamofireImage 的编译器错误:
是我的问题,还是 AlamofireImage 根本无法在 Swift 4 中工作?我正在尝试像这样设置图像缓存(Swift 3 代码):
Alamofire.request(urlString)
.responseImage { response in
if let downloadedImage = response.result.value {
// image is here.
imageCache.setObject(downloadedImage, forKey: urlString as NSString)
self.image = downloadedImage
}
}
【问题讨论】:
-
您使用的是最新版本的 swift,但 alamofire pod 并未按照最新版本进行更新,这就是您遇到错误的原因
-
运行 pod install 以更新 pod 并删除任何版本约束
-
在 pod install 命令仍未修复后,然后转到 pod 设置选择 alamofire 并在构建设置中选择适当的 swift 版本。
标签: swift xcode swift4 alamofire alamofireimage