【问题标题】:Swift Alamofire building error Identifier Name ViolationSwift Alamofire 构建错误标识符名称违规
【发布时间】:2021-04-16 12:53:22
【问题描述】:

尝试构建 Alamofire,但在此函数中收到错误 Identifier Name Violation: Variable name should start with a lowercase character: 'W' (identifier_name)

var readableDescription: String {
        let W = isCellular ? "W" : "-"
        let R = isReachable ? "R" : "-"
        let c = isConnectionRequired ? "c" : "-"
        let t = contains(.transientConnection) ? "t" : "-"
        let i = contains(.interventionRequired) ? "i" : "-"
        let C = contains(.connectionOnTraffic) ? "C" : "-"
        let D = contains(.connectionOnDemand) ? "D" : "-"
        let l = contains(.isLocalAddress) ? "l" : "-"
        let d = contains(.isDirect) ? "d" : "-"
        let a = contains(.connectionAutomatic) ? "a" : "-"

        return "\(W)\(R) \(c)\(t)\(i)\(C)\(D)\(l)\(d)\(a)"
    }

很少有这个错误Type Name Violation: Type name should only contain alphanumeric characters: '_URLEncodedFormEncoder' (type_name)在名称final class _URLEncodedFormEncoder

也许我在项目中禁用了某些东西?在我没有看到这个错误之前

【问题讨论】:

  • 这意味着let W 应该是let w。但这似乎与 Swiftlint 有关,不是吗?或任何其他 linter,而不是 Alamofire。将 Swiftlint 的设置设置为不对您的 CocoaPods/Carthage、任何第三方库进行 lint。见github.com/realm/SwiftLint/issues/1423
  • @Larme 是的,它是 swiftlint。谢谢你。你可以发布一个答案,我会接受的

标签: swift alamofire


【解决方案1】:

您通常希望忽略格式化和列表工具中的依赖关系。要为 SwiftLint 这样做,请将您的依赖目录添加到您的 SwiftLint 排除列表中。例如,如果您使用的是 CocoaPods:

excluded: # paths to ignore during linting. Takes precedence over `included`.
   - Pods

【讨论】:

    猜你喜欢
    • 2021-05-13
    • 2014-11-23
    • 1970-01-01
    • 2022-01-17
    • 2019-02-16
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 2020-06-20
    相关资源
    最近更新 更多