Skip to content

[tool] Include Swift in warning-as-error modes - #13284

Draft
stuartmorgan wants to merge 8 commits into
flutter:mainfrom
stuartmorgan:swift-warnings-as-errors
Draft

stuartmorgan wants to merge 8 commits into
flutter:mainfrom
stuartmorgan:swift-warnings-as-errors

Conversation

@stuartmorgan

@stuartmorgan stuartmorgan commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Testing addition of SWIFT_TREAT_WARNINGS_AS_ERRORS.

See flutter/flutter#194517

@stuartmorgan stuartmorgan changed the title [tool] Included Swift in warning-as-error modes [tool] Include Swift in warning-as-error modes Oct 16, 2026
@stuartmorgan stuartmorgan added the CICD Run CI/CD label Oct 16, 2026
extraFlags: <String>[
...extraFlags,
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
'SWIFT_TREAT_WARNINGS_AS_ERRORS=YES',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not is wacky, but I think it'll work...

  r'SWIFT_TREAT_WARNINGS_AS_ERRORS=$(SWIFT_SUPPRESS_WARNINGS:not)',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took the liberty of pushing a commit, let's see what happens.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it worked. Now there's a pile of Swift analyzer warnings.

@jmagman
jmagman force-pushed the swift-warnings-as-errors branch from af771cc to 4778091 Compare October 19, 2026 23:18
@jmagman
jmagman force-pushed the swift-warnings-as-errors branch from 4dd02c2 to 9893147 Compare October 19, 2026 23:38
auto-submit Bot pushed a commit that referenced this pull request Oct 20, 2026
I don't know why these analyzer issues are being reported one-at-a-time in CI on #13284 instead of all at once, but #13332 was only one of a few analyzer issues:
```
darwin/Tests/CameraSessionPresetsTests.swift:28:9: error: variable 'currentFormat' was never mutated; consider changing to 'let' constant
    var currentFormat: CaptureDeviceFormat = captureFormatMock
    ~~~ ^
    let
darwin/Tests/CameraInitRaceConditionsTests.swift:62:24: warning: immutable value '_captureSessionQueue' was never used; consider replacing with '_' or removing it [#NoUsage]
60 | 
61 |   func testFlutterChannelInitializedWhenStartingImageStream() {
62 |     let (cameraPlugin, _captureSessionQueue) = createCameraPlugin()
darwin/Tests/AvailableCamerasTests.swift:49:11: warning: variable 'requiredTypes' was never mutated; consider changing to 'let' constant [#VariableNeverMutated]
 47 |       telephotoCamera.position = .back
 48 | 
 49 |       var requiredTypes: [AVCaptureDevice.DeviceType] = [
darwin/Tests/AvailableCamerasTests.swift:52:11: warning: variable 'cameras' was never mutated; consider changing to 'let' constant [#VariableNeverMutated]
 50 |         .builtInWideAngleCamera, .builtInTelephotoCamera, .builtInUltraWideCamera,
 51 |       ]
 52 |       var cameras = [wideAngleCamera, frontFacingCamera, telephotoCamera, ultraWideCamera]
darwin/Tests/AvailableCamerasTests.swift:86:11: warning: variable 'requiredTypes' was never mutated; consider changing to 'let' constant [#VariableNeverMutated]
 84 |       frontFacingCamera.position = .front
 85 | 
 86 |       var requiredTypes: [AVCaptureDevice.DeviceType] = [
darwin/Tests/AvailableCamerasTests.swift:118:11: warning: variable 'requiredTypes' was never mutated; consider changing to 'let' constant [#VariableNeverMutated]
116 |       unspecifiedCamera.position = .unspecified
117 | 
118 |       var requiredTypes: [AVCaptureDevice.DeviceType] = [
darwin/Tests/CameraOrientationTests.swift:120:14: warning: weak variable 'weakDevice' was never mutated; consider changing to 'let' constant [#VariableNeverMutated::WeakMutability]
118 |     let captureSessionQueue = DispatchQueue(label: "capture_session_queue")
119 |     weak var weakPlugin: CameraPlugin?
120 |     weak var weakDevice = mockDevice
darwin/Tests/CameraOrientationTests.swift:157:14: warning: weak variable 'weakEventAPI' was never mutated; consider changing to 'let' constant [#VariableNeverMutated::WeakMutability]
155 |     }
156 | 
157 |     weak var weakEventAPI = mockEventAPI

```

This wasn't showing up in CI due to flutter/flutter#194517.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
@stuartmorgan

Copy link
Copy Markdown
Contributor Author

I think once the last image_picker Swift PR lands it'll just be the IAP deprecation warnings.

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

Labels

CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants