gpt4 book ai didi

swift - Swift 4 中的 AlamofireImage 问题

转载 作者:行者123 更新时间:2023-11-30 11:05:50 26 4
gpt4 key购买 nike

我正在尝试在一个使用 Swift 4 编码的项目中使用 AlamofireImage。pod 安装顺利,但是当我导入模块时,出现错误“无法构建 Objective-c 模块 AlamofireImage”

我还注意到一些有关 AlamofireImage 的编译器错误:

enter image description here

我这边有问题吗,还是 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
}
}

最佳答案

退出 Xcode,转到终端,然后转到项目目录并输入以下命令:

pod install

确保你的 pod 文件如下所示

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'SwiftNetworking' do
pod 'Alamofire', '~> 4.7'
pod 'AlamofireNetworkActivityIndicator', '~> 2.2'
pod 'SwiftyJSON', '~> 4.0'
end

关于swift - Swift 4 中的 AlamofireImage 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52740750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com