0

我正在尝试在使用 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
            }
    }
4

1 回答 1

0

退出 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
于 2018-10-11T09:13:40.377 回答