Skip to content

Rule Request: "Legacy UIGraphics functions" #6268

Closed

Description

@DimDL

We could have a legacy_uigraphics_functions, which can already be defined as a custom rule:

custom_rules:
  legacy_uigraphics_functions:
    included: ".*\\.swift"
    name: "Legacy UIGraphics functions"
    regex: "(UIGraphicsBeginImageContextWithOptions|UIGraphicsBeginImageContext|UIGraphicsGetImageFromCurrentImageContext|UIGraphicsEndImageContext)\\s*\\("
    message: "This UIGraphics method is deprecated. Use UIGraphicsImageRenderer and related APIs instead."
    severity: warning

These 4 methods are already marked API_TO_BE_DEPRECATED in UIKit Headers.
This new rule would match existing SwiftLint rule such as legacy_cggeometry_functions and legacy_nsgeometry_functions

  1. configurable: no
  2. opt-in: yes, to match existing rules legacy_*_functions ? The replacement API (UIGraphicsImageRenderer) exists since iOS 10.

Activity

  1. added
    rule-request
    on Oct 1, 2025
  2. ZevEisenberg commented on May 27, 2026

    @ZevEisenberg
    Contributor

    FYI, the release notes for the version that released this calls it legacy_uigraphics_functions, but the rule as implemented in #6269 is called legacy_uigraphics_function (no trailing s).

  3. SimplyDanny commented on May 27, 2026

    @SimplyDanny
    Collaborator

    FYI, the release notes for the version that released this calls it legacy_uigraphics_functions, but the rule as implemented in #6269 is called legacy_uigraphics_function (no trailing s).

    Thanks for the note, @ZevEisenberg! I've updated the name in the release notes.

  4. ZevEisenberg commented on May 27, 2026

    @ZevEisenberg
    Contributor

    Ditto the changelog entry in that PR

  5. SimplyDanny commented on May 27, 2026

    @SimplyDanny
    Collaborator

    Ditto the changelog entry in that PR

    813c7d3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule-request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions