0

由于苹果不再支持 UIWebview,是否有可能为此发出 swift-lint 警告。

如何使自定义 UIWebview 使用 swift-lint 警告或错误。

4

1 回答 1

0

定义自定义规则的示例在这里(没有自己测试,可能正则表达式需要一些返工)。您可以查看https://github.com/realm/SwiftLint页面上提供的 swiftlint 示例,位于定义自定义规则部分下。

custom_rules:
  uiwebview_deprecated: # rule identifier
  included: ".*\\.swift" # regex that defines paths to include during linting. optional.
  excluded: ".*Test\\.swift" # regex that defines paths to exclude during linting. optional
  name: "UIWebView deprecated" # rule name. optional.
  regex: "(UIWebView)" # matching pattern
  capture_group: 0 # number of regex capture group to highlight the rule violation at. optional.
  match_kinds: # SyntaxKinds to match. optional.
    - comment
    - identifier
  message: "UIWebView are deprecated, use WKWebView instead." # violation message. optional.
  severity: error # violation severity. optional.
no_hiding_in_strings:
  regex: "(UIWebView)"
  match_kinds: string
于 2020-03-19T09:04:19.780 回答