Sitelet https://github.com/MessageKit/MessageKit/pull/1906
Skip to content

Remove dead code from the example app - #1906

Merged
Kaspik merged 1 commit into
fix/example-runtime-bugsfrom
chore/example-dead-code
Aug 20, 2026
Merged

Remove dead code from the example app#1906
Kaspik merged 1 commit into
fix/example-runtime-bugsfrom
chore/example-dead-code

Conversation

@martinpucik

Copy link
Copy Markdown
Contributor

Stacked on #1905. Review that one first; this PR targets its branch so the diff stays clean.

Removes code and resources that nothing references. No behaviour changes except the two noted at the end.

Dead code

What Why it is dead
AdvancedExampleViewController.makeButton(named:) private, no caller. Also captured self strongly in its tap handler.
CameraInputBarAccessoryView.makeButton(named _:) Ignored its argument and hardcoded UIImage(systemName: "camera.fill"). configure() then replaced its onTouchUpInside, so the handler never ran. Now makeCameraButton(), no parameter.
Sources/Resources/sound1.m4a Byte-identical to Sources/Sounds/sound1.m4a (same MD5) and in no build phase.
13 image sets Nothing loads them: Dan-Leonard, Steve-Jobs, Tim-Cook, pin, ic_appstore, ic_camera, ic_info, ic_keyboard, ic_library, ic_like, ic_mic, ic_send, ic_typing.
let topStackView = topStackView Shadowed the property with itself.
3 commented-out statements

mklogo looked unused from Swift but the launch storyboard references it, so it stays.

Two small behaviour fixes

Section headers now appear. LaunchViewController.Section carried a title — "Examples" and "Support" — but the controller never implemented titleForHeaderInSection, so neither was ever drawn. Rows also deselect after a tap now.

didSelectRowAt no longer repeats itself. Six of the eleven cases spelled out the same "wrap in a nav controller, then showDetailViewController" three-liner. A showDetail(_:wrapInNavigationController:) helper replaces them.

That repetition is what made the switch long enough to carry // swiftlint:disable cyclomatic_complexity, which is now gone. It was doing nothing anyway — .swiftlint.yml excludes Example, and cyclomatic_complexity is not among its only_rules.

Test

ChatExampleTests was an empty testExample plus empty setUp/tearDown overrides. It now tests the randomMessageType() fallback that #1905 adds.

Also

  • MockSocket.shared becomes a let; nothing reassigned it.
  • SwiftUIExampleView dropped its if #available(iOS 14.0, *) branch and the IgnoresSafeArea wrapper around it. The deployment target is 15.0, so the else was unreachable.
  • ChatViewController.messageList was lazy var ... = [], which buys nothing on an empty array literal.
  • "Custom data detector patter selected" → "pattern".

Verification

Built for an iPhone 17 simulator (iOS 27). Both the new unit test and the UI test from #1905 pass, so all 8 examples still open and render.

🤖 Generated with Claude Code

Nothing referenced any of this:

- `AdvancedExampleViewController.makeButton(named:)` was private and had
  no caller. It also captured `self` strongly in its tap handler, so it
  was a retain cycle waiting for someone to call it.
- `CameraInputBarAccessoryView.makeButton(named _:)` ignored the name it
  was given and hardcoded an SF Symbol. Its tap handler was replaced by
  `configure()` straight after, so the handler never ran either. It is
  now `makeCameraButton()` with no parameter.
- `Sources/Resources/sound1.m4a` is byte-identical to
  `Sources/Sounds/sound1.m4a` and is in no build phase.
- 13 image sets nothing loads. `mklogo` stays; the launch storyboard
  uses it.
- `let topStackView = topStackView` shadowed the property with itself.
- Three commented-out statements.

`LaunchViewController` set a title on each section but never implemented
`titleForHeaderInSection`, so "Examples" and "Support" never appeared.
They do now. Its `didSelectRowAt` repeated the same three lines for each
row; a `showDetail` helper replaces them, which removes the need for the
`swiftlint:disable cyclomatic_complexity` pragma. That pragma did
nothing regardless: `.swiftlint.yml` excludes `Example`, and
`cyclomatic_complexity` is not in `only_rules`. Rows also deselect now.

`ChatExampleTests` held an empty `testExample` plus empty `setUp` and
`tearDown`. It now covers the `randomMessageType()` fallback.

Also `MockSocket.shared` is a `let`, the availability check for iOS 14
in `SwiftUIExampleView` is gone (the target is 15.0), `messageList` is
no longer pointlessly `lazy`, and a "patter" typo is fixed.
@Kaspik
Kaspik merged commit f5fbd78 into main Aug 20, 2026
5 checks passed
@Kaspik
Kaspik deleted the chore/example-dead-code branch August 20, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants