Skip to content

Modernize to Swift 5 and add unit tests#1

Open
umarF wants to merge 1 commit into
masterfrom
claude/session-06dcqo
Open

Modernize to Swift 5 and add unit tests#1
umarF wants to merge 1 commit into
masterfrom
claude/session-06dcqo

Conversation

@umarF

@umarF umarF commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

This project was written in Swift 3.0 (2017, Xcode 8.3, iOS 10.3) and no longer compiled on modern Xcode because it depended on APIs that have since been renamed or removed. This PR modernizes the code to Swift 5 / iOS 13+, refactors the models and selection logic, and adds a unit-test target.

Source modernization

  • Replaced removed/renamed APIs:
    • NSFontAttributeName / NSForegroundColorAttributeNameNSAttributedString.Key
    • UITableViewAutomaticDimensionUITableView.automaticDimension
    • UIApplicationLaunchOptionsKeyUIApplication.LaunchOptionsKey
    • .index(where:).firstIndex(where:)
  • protocol sectionTappedDelegate: classSectionTappedDelegate: AnyObject.
  • TeamModel / LeagueModel now have real initializers (memberwise + dictionary) and synthesized Equatable/Hashable, replacing the mutating setEmptyObject/setTeams/setLeague helpers and the hand-rolled isEqualTeamModel/isEqualLeagueModel free functions.
  • Extracted all selection bookkeeping out of the view controller into a new pure, UIKit-independent MultiSelectionModel. MultiApprovalController is now a thin table-view layer.

Behavioural fix

The original code tracked selection by value (isEqualTeamModel), so two teams that compared equal in different sections were treated as one selection. MultiSelectionModel tracks selection by position (section, row), so each row is independent. A section header is selected only when every row in it is selected.

Project modernization

  • Swift 3.05.0, iOS deployment target 10.313.0, objectVersion 4656.
  • Added a .gitignore for Xcode / SwiftPM build artifacts and per-user data.

Tests

Added a MultiSelectHeaderTests logic-test target (with a shared scheme) covering:

  • Model initializers, dictionary mapping, and equality.
  • The full selection state machine: single-row toggle, section toggle (select-all / clear-all), header auto-selection, positional (non-value-based) selection, selected-order stability, and empty / out-of-range edge cases.

Run with Cmd+U or:

xcodebuild test -project MultiSelectHeader.xcodeproj -scheme MultiSelectHeader \
  -destination 'platform=iOS Simulator,name=iPhone 15'

Verification note

This PR was prepared in a Linux environment with no Xcode/Swift toolchain, so it was not compiled or run here. Changes were made against the public UIKit/Swift 5 API surface, and the modified project.pbxproj was validated for balanced structure and no dangling object references. Please run a build + the test target in Xcode/CI before merging.

🤖 Generated with Claude Code


Generated by Claude Code

Bring this 2017-era Swift 3 project up to modern standards. The code no
longer compiled on current Xcode because it relied on APIs that have since
been renamed or removed.

Source modernization:
- Replace removed/renamed APIs: NSFontAttributeName/NSForegroundColorAttributeName
  -> NSAttributedString.Key, UITableViewAutomaticDimension ->
  UITableView.automaticDimension, UIApplicationLaunchOptionsKey ->
  UIApplication.LaunchOptionsKey, .index(where:) -> .firstIndex(where:).
- `protocol sectionTappedDelegate: class` -> `SectionTappedDelegate: AnyObject`.
- Give TeamModel/LeagueModel real initializers (memberwise + dictionary) and
  synthesized Equatable/Hashable, replacing the mutating setEmptyObject/setTeams
  helpers and the hand-rolled isEqual* free functions.
- Extract all selection bookkeeping out of the view controller into a pure,
  UIKit-independent MultiSelectionModel. Selection is now tracked by position
  instead of by value, fixing a latent bug where equal teams in different
  sections were treated as the same selection.
- Slim MultiApprovalController down to a thin table-view layer.

Project modernization:
- Swift 3.0 -> 5.0, iOS deployment target 10.3 -> 13.0, objectVersion 46 -> 56.
- Add a .gitignore for Xcode/SwiftPM artifacts and per-user data.

Tests:
- Add a MultiSelectHeaderTests logic-test target with a shared scheme.
- Cover the model initializers/equality and the full selection state machine
  (single toggle, section toggle, header auto-selection, positional selection,
  ordering, and empty/out-of-range edge cases).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uhsa6djvaVngWNbG56ZQyx
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