Skip to content

Modernize CapsuleView for Swift 5 / current Xcode#1

Open
umarF wants to merge 1 commit into
masterfrom
claude/code-modernization-review-5f7etl
Open

Modernize CapsuleView for Swift 5 / current Xcode#1
umarF wants to merge 1 commit into
masterfrom
claude/code-modernization-review-5f7etl

Conversation

@umarF

@umarF umarF commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

Modernizes the 2018-era CapsuleView component (Swift 4.0 / iOS 11) so it compiles on a current Xcode toolchain, removes some latent crashes, and de-duplicates internal logic. The public API is unchanged — existing Storyboard/programmatic usage keeps working.

Scope was agreed as Tier 1 + Tier 2; the source-breaking renames (misspelled property names, enum-typed parameters, SwiftPM) were intentionally left out for a possible future major version.

Tier 1 — Compile on modern toolchains + repo hygiene

  • Replace deprecated APIs that no longer compile:
    • UIViewAutoresizingUIView.AutoresizingMask
    • UIApplicationLaunchOptionsKeyUIApplication.LaunchOptionsKey
    • @UIApplicationMain@main
    • bringSubview(toFront:)bringSubviewToFront(_:) (demo + README)
  • Remove needless force-unwraps (self.label.text! = …, bgColor!) and guard the borderColor / shadowColor getters against a nil CGColor — previously these could crash.
  • Bump SWIFT_VERSION to 5.0 and deployment target to iOS 13; update Xcode upgrade-check markers.
  • Add .gitignore, untrack committed xcuserdata/ (two users' UI state, breakpoints, schemes), update README (Swift 3.0+Swift 5).

Tier 2 — Internal refactors (non-breaking)

  • Collapse the two near-identical FontType / FontType2 enums into one FontSize enum.
  • De-duplicate the custom init(...) by delegating to setupViewDynamic(...).
  • Table-drive setAllignment() through the existing (previously unused) TextAllignment enum instead of two magic-number switches.
  • Make the @IBInspectable didSet observers nil-safe during Storyboard decode ordering.

CI / verification

This project is a UIKit app and cannot be built on a Linux environment, so I added:

  • A shared CapsuleView scheme (the old scheme lived in the now-untracked xcuserdata).
  • A GitHub Actions macOS workflow (.github/workflows/ci.yml) that builds the project for the iOS Simulator on every push/PR to master.

⚠️ Please confirm the build via the CI run (or a local Xcode build) before merging — I was unable to compile locally. Note: CapsuleViewTests/ is not wired as a build target in the project, so CI runs build only, not test.

🤖 Generated with Claude Code


Generated by Claude Code

Tier 1 — compile on modern toolchains + repo hygiene:
- Replace deprecated APIs: UIViewAutoresizing -> UIView.AutoresizingMask,
  UIApplicationLaunchOptionsKey -> UIApplication.LaunchOptionsKey,
  @UIApplicationMain -> @main, bringSubview(toFront:) -> bringSubviewToFront(_:)
- Remove needless force-unwraps and guard the borderColor/shadowColor
  getters against a nil CGColor (previously could crash)
- Bump SWIFT_VERSION to 5.0 and deployment target to iOS 13
- Add .gitignore, untrack committed xcuserdata, update README

Tier 2 — internal refactors (public API unchanged):
- Collapse duplicate FontType/FontType2 into a single FontSize enum
- De-duplicate the custom init by delegating to setupViewDynamic
- Table-drive setAllignment via the existing TextAllignment enum
- Make IBInspectable didSet observers nil-safe during storyboard decode

CI:
- Add shared CapsuleView scheme and a GitHub Actions macOS workflow
  that builds the project for the iOS Simulator

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