Skip to content

swift, objc: strict by default (warnings as errors, Swift 6, SwiftLint strict tier) #14680

Open

Description

@TrapsterDK

Where

  • swift/rules/defs.bzl:20-83: wrappers add features only. No -warnings-as-errors, no Swift 6 mode.
  • swift/toolchain/toolchain.bzl:104: upcoming features supported, none on.
  • quality/tiers/swift_format/{standard,strict}.json: differ only in NeverForceUnwrap, NeverUseForceTry, NeverUseImplicitlyUnwrappedOptionals.
  • quality/native_config.bzl:50: swift_lint reuses the swift_format config. No SwiftLint tier.
  • quality/tools.bzl:2471, 2493, 1710: swift_format, swift_lint, periphery, no severity().
  • families/apple: no ObjC copts.
  • docs/cli/commands/quality.md:210-211, 407-424: no Swift tier row.

Fix

Guard rules (do first):

  • swift_format default tier: NeverForceUnwrap, NeverUseForceTry, NeverUseImplicitlyUnwrappedOptionals on.
  • SwiftLint at error: force_unwrapping, force_cast, force_try, implicitly_unwrapped_optional, fatal_error_message, unhandled_throwing_task, unavailable_function, todo, custom_rules for print( and debugPrint(.
  • Swift 6 mode (-swift-version 6) so @unchecked Sendable misuse and data races fail. ExistentialAny. -strict-memory-safety.
  • ObjC: -fobjc-arc, -Wnullability-completeness, -Wnullable-to-nonnull-conversion, -Wimplicit-retain-self.

Then:

  • Default swift copts: -warnings-as-errors, -swift-version 6, -enable-upcoming-feature for ExistentialAny, InternalImportsByDefault, MemberImportVisibility, NonisolatedNonsendingByDefault, InferIsolatedConformances, ImmutableWeakCaptures; -require-explicit-sendable; -Xfrontend -warn-implicit-overrides. Opt out with treat_warnings_as_errors = False.
  • objc_library copts: -Werror -Weverything -fobjc-arc-exceptions -Wobjc-messaging-id -Wdeprecated-implementations with -Wno-objc-missing-property-synthesis -Wno-direct-ivar-access -Wno-padded -Wno-poison-system-directories -Wno-cast-align -Wno-unused-macros -Wno-declaration-after-statement -Wno-pre-c11-compat -Wno-gnu-zero-variadic-macro-arguments -Wno-covered-switch-default.
  • New quality/tiers/swift_lint/{standard,strict}.yml with unowned_variable_capture, discarded_notification_center_observer, weak_delegate, legacy_objc_type, discouraged_optional_boolean, explicit_acl, redundant_nil_coalescing, class_delegate_protocol. Drop the swift_format alias in native_config.bzl:50; add swift_lint_config.
  • severity() maps for swift_lint, swift_format, periphery. Add the Swift tier row to quality.md.

Excluded

-enable-experimental-feature, Embedded, Lifetimes, -strict-concurrency=complete. SwiftLint trailing_whitespace, line_length, vertical_whitespace, opening_brace, sorted_imports, explicit_self, no_magic_numbers, strict_fileprivate, missing_docs, file_header, type_contents_order, prefer_self_in_static_references, explicit_type_interface, file_name, required_deinit, analyzer rules. -warn-long-expression-type-checking.

Test

  • Analysis tests: the copts appear on swift_library and objc_library.
  • tiers_test.rs covers the swift_lint tiers.
  • Negative fixture per guard (try!, as!, !, print, TODO, any-less existential, @unchecked Sendable race) fails.
  • Clean fixture passes. tier = "standard" still passes.

Verify every rule ID and flag against the pinned tool version before landing; some come from memory.

Part of #14647

Activity

  1. added
    local
    on Nov 22, 2026
  2. TrapsterDK commented on Nov 22, 2026

    @TrapsterDK
    CollaboratorAuthor

    Paths in this issue are from an old layout. Branch from origin/main; quality code is in core/quality/, wrappers in /private/. Rebase on #14647 (strict default) and #14685 (severity floor).

    Related: #14689 covers cc_objc_library werror, strict concurrency and swift_lint as a default linter.

    🤖 Generated with Claude Code

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

    local

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions