r/swift • • 3d ago

I built an open-source GitHub Action that implements issues & opens tested PRs using modern Swift 6 & Xcode 27 rules

Hey everyone,

Like many of you, I've tried using AI coding assistants on iOS projects, but was constantly frustrated by:

  1. AI generating outdated iOS 14 / UIKit boilerplate instead of modern Swift 6 / SwiftUI APIs.
  2. Redundant wrapper views (like unnecessary Group { ... } wrappers or .foregroundStyle(.primary)).
  3. AI making an edit, breaking the build, and giving up.

I built PR Forge (pr-forge-ai), an open-source agent that runs in GitHub Actions or your local terminal.

When you comment /forge on an issue: • It detects the project type (SwiftPM or Xcode .xcodeproj). • Applies progressive skills: u/State macro rules, .glassEffect(), WebView/WebPage in SwiftUI, InlineArray, and functional Swift idioms. • Runs swift test or xcodebuild. • Self-audits every checkbox in your issue PRD. • Pushes a commit under PR Forge Bot and opens a PR.

We tested it end-to-end on a live macOS Swift project (Spreading Aroma), where it autonomously built a node statistics counter, code optimizer, and unit test suites that passed CI and merged cleanly.

Repo: https://github.com/shubhransh-gupta/pr-forge

What are the most annoying Swift/Xcode boilerplate patterns you'd want an autonomous agent to automate?

1 Upvotes

3 comments sorted by

1

u/Needle_In_Red 5h ago

cool idea, ai usualy gets the old uikit stuff wrong so the modern rules part is smart. does it handle the build fail retry loop ok?

1

u/Oxnull-shubh 5h ago

Appreciate it! Yeah, keeping legacy UIKit patterns (UIScreen.main, topLayoutGuide, etc.) out of the prompt via targeted skill files made a huge difference.

On the retry loop: it runs a bounded verify-and-iterate loop (max_iterations). Each pass applies minimal search/replace patches, runs the detected swift test / xcodebuild command, and if it fails, feeds the compiler error tail + a rolling state ledger back into the next patch attempt. It won't auto-commit until the build is green and the PR's acceptance criteria pass—if it hits the iteration cap, it reports the exact remaining build/gap status instead of pushing broken code. (For xcodebuild targets in CI, you just need a macOS runner.)

1

u/Royal-Subject2870 2h ago

Interesting approach with the bounded retry loop. One failure mode I've seen with AI-assisted Swift that's particularly nasty: macro-generated code (`@Observable`, `@Model`, newer`@Entry` for SwiftUI) sometimes produces compiler errors that reference the macro expansion, not the source line the user wrote. The error message is correct but points to "generated code line 42" which doesn't exist in any file. Does PR Forge normalize those back to source positions before feeding them into the next iteration?

Also curious about Package.resolved conflicts. When the agent adds a dependency, does it attempt to resolve version mismatches with existing pins, or does it just let the next `swift package resolve` fail?