KingFisher 5.12.0 的 Linting 错误 - Swift 5.1.2

Posted

技术标签:

【中文标题】KingFisher 5.12.0 的 Linting 错误 - Swift 5.1.2【英文标题】:Linting errors with KingFisher 5.12.0 - Swift 5.1.2 【发布时间】:2019-12-21 21:18:03 【问题描述】:

在我的项目中的 Kingfisher 库上运行 swiftlint 时出现以下错误。我正在运行 Swift 5.1.2 XCode 11.2.1

Testing failed:
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Cannot convert value of type '() -> ImageDownloader' to expected argument type '((_, SessionDelegate.SessionChallengeFunc) -> Void)?' (aka 'Optional<(_, (URLSession, URLAuthenticationChallenge, (URLSession.AuthChallengeDisposition, Optional<URLCredential>) -> ())) -> ()>')
    Cannot convert value of type '() -> ImageDownloader' to expected argument type '((_, SessionDelegate.SessionTaskChallengeFunc) -> Void)?' (aka 'Optional<(_, (URLSession, URLSessionTask, URLAuthenticationChallenge, (URLSession.AuthChallengeDisposition, Optional<URLCredential>) -> ())) -> ()>')
    Cannot convert value of type '() -> ImageDownloader' to expected argument type '((_, Int) -> Bool)?'
    Cannot convert value of type '() -> ()' to expected argument type '((_, (URL, Result<URLResponse, KingfisherError>)) -> Void)?'
    Use of unresolved identifier 'task'
    Use of unresolved identifier 'task'
    Unable to infer complex closure return type; add explicit type to disambiguate
    Cannot convert value of type '() -> ()' to expected argument type '((_, (Result<(Data, URLResponse?), KingfisherError>, [SessionDataTask.TaskCallback])) -> Void)?'
    Expected ',' separator
    Consecutive statements on a line must be separated by ';'
    Consecutive statements on a line must be separated by ';'
    Expected expression
    Cannot convert value of type '() -> ()' to expected argument type '((_, (SessionDataTask.CancelToken, SessionDataTask.TaskCallback)) -> Void)?' (aka 'Optional<(_, (Int, SessionDataTask.TaskCallback)) -> ()>')
    Command MergeSwiftModule failed with a nonzero exit code
    Insufficient indentation of next 2 lines in multi-line string literal
    Command CompileSwift failed with a nonzero exit code
    Testing cancelled because the build failed.

我尝试了以下方法: 快速运行 swiftformat 。 swiftlint 自动更正

但没有骰子,我将它安装为 cocoapod。在我打开 Kingfisher 项目本身的问题之前,我要在这里问。

【问题讨论】:

【参考方案1】:

当 swiftFormat 的脚本自动更正 Kingfisher pod 时,我遇到了一个非常相似的问题。您需要手动删除 pod(或通过pod deintegrate),重新安装它(以反转更改),然后,如果像我一样,您在构建阶段将 swiftlint 作为脚本调用,将其更改为

"$PODS_ROOT/SwiftFormat/CommandLineTool/swiftformat" . --exclude Pods,Generated

【讨论】:

以上是关于KingFisher 5.12.0 的 Linting 错误 - Swift 5.1.2的主要内容,如果未能解决你的问题,请参考以下文章

将使用 Kingfisher 下载的图像保存到文档目录

IOS Rxswift 使用 Kingfisher 预取 cell Image

如何在 swift 中使用 kingFisher 库中的 AspectScaledToFitAndCenterSizeFilter

为啥我在使用 kingfisher 将图像从 JSON 加载到 tableview 时出错?

Alamofire + kingfisher Https 自签名证书

仅使用Kingfisher库获取UIImage