Skip to content

feat: improve ux on first time swift package runtime setup#6064

Merged
NathanWalker merged 2 commits into
mainfrom
feat/xcodebuild-progress
Jun 26, 2026
Merged

feat: improve ux on first time swift package runtime setup#6064
NathanWalker merged 2 commits into
mainfrom
feat/xcodebuild-progress

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Improves the Swift Package Manager (SPM) dependency resolution process for iOS projects, ensuring that potentially slow package downloads happen under a clear progress spinner instead of appearing to stall the build.

Summary by CodeRabbit

  • New Features

    • Swift Package Manager dependencies are now resolved earlier in iOS builds, including a best-effort pre-check for existing resolution artifacts.
    • iOS build/SwiftPM resolution can stream progress updates to the caller for smoother, responsive progress indicators.
  • Bug Fixes

    • Improved SPM workflow: app/plugin package override handling and clearer activity/progress labeling during resolution.
    • More reliable progress handling: guaranteed cleanup on failures and better trace/warnings when pre-resolution fails.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a89dc927-0774-4e20-9f59-5d7ed5c07967

📥 Commits

Reviewing files that changed from the base of the PR and between 4f13072 and cc02cc6.

📒 Files selected for processing (2)
  • lib/services/ios/spm-service.ts
  • test/spm-service.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/services/ios/spm-service.ts

📝 Walkthrough

Walkthrough

iOS type declarations add SPM resolution methods and xcodebuild progress callbacks. XcodebuildCommandService streams output chunks to callers. SPMService adds progress-aware resolution, preflight checks, and log parsing. IOSProjectService.buildProject now waits for SPM pre-resolution.

Changes

iOS SPM progress and preflight resolution

Layer / File(s) Summary
Public contracts
lib/definitions/ios.d.ts
ISPMService adds resolveSPMDependencies and ensureSPMDependenciesResolved, IXcodebuildCommandOptions adds onProgress, and nearby signatures are reformatted.
xcodebuild progress piping
lib/services/ios/xcodebuild-command-service.ts
executeCommand accepts onProgress, pipes build output chunks to the callback, and always removes the progress listener in finally.
SPM resolution runtime
lib/services/ios/spm-service.ts
SPMService injects file-system and spinner services, updates package merge bookkeeping, and runs progress-aware SwiftPM resolution with log-to-activity parsing.
SPM preflight check
lib/services/ios/spm-service.ts, lib/services/ios-project-service.ts, test/ios-project-service.ts
Filesystem checks gate best-effort pre-resolution, buildProject awaits the precheck, and the test injector stubs the new service method.
SPM test coverage
test/spm-service.ts
SPMService tests cover package merge assertions and new log parsing helpers, with the local test setup updated for the new import.

Sequence Diagram(s)

sequenceDiagram
  participant IOSProjectService
  participant SPMService
  participant XcodebuildCommandService
  participant xcodebuild
  participant ITerminalSpinnerService

  IOSProjectService->>SPMService: ensureSPMDependenciesResolved(platformData, projectData)
  SPMService->>SPMService: hasSPMReferences() / arePackagesResolved()
  SPMService->>SPMService: resolveSPMDependencies(..., { showProgress: true })
  SPMService->>XcodebuildCommandService: executeCommand(..., onProgress)
  XcodebuildCommandService->>xcodebuild: spawn with piped stdio
  xcodebuild-->>XcodebuildCommandService: BUILD_OUTPUT_EVENT_NAME chunks
  XcodebuildCommandService-->>SPMService: onProgress(chunk)
  SPMService->>ITerminalSpinnerService: update activity / succeed / fail
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • triniwiz

Poem

A bunny hopped through SwiftPM logs,
With spinner twirls and xcodebuild jogs.
It sniffed the chunks, then thumped with glee,
“Resolved at last! Now build with me!” 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main goal of improving first-time Swift Package setup UX, including clearer progress during package resolution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/services/ios/xcodebuild-command-service.ts (1)

16-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the IXcodebuildCommandOptions interface instead of an inline duplicate.

The inline options shape here re-declares the public IXcodebuildCommandOptions contract (lib/definitions/ios.d.ts). Keeping two copies invites silent drift if the interface evolves. Consider typing the parameter as IXcodebuildCommandOptions.

♻️ Proposed change
 	public async executeCommand(
 		args: string[],
-		options: {
-			cwd: string;
-			stdio?: string;
-			message?: string;
-			spawnOptions?: any;
-			// When provided, xcodebuild's output is piped (rather than inherited)
-			// and forwarded here line-by-line so the caller can render its own
-			// progress UI (e.g. a spinner for SPM resolution/download activity).
-			onProgress?: (chunk: { data: string; pipe: string }) => void;
-		},
+		options: IXcodebuildCommandOptions,
 	): Promise<ISpawnResult> {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/ios/xcodebuild-command-service.ts` around lines 16 - 28, The
executeCommand method in XcodebuildCommandService is using an inline options
object that duplicates the public IXcodebuildCommandOptions contract. Update the
method signature to reference IXcodebuildCommandOptions directly so the
implementation stays aligned with the shared type and avoids future drift; use
the existing executeCommand symbol in XcodebuildCommandService and the
IXcodebuildCommandOptions interface from the ios definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/services/ios/spm-service.ts`:
- Around line 116-122: The failure in applySPMPackages is being swallowed by the
surrounding try/catch, so the red spinner error from resolveSPMDependencies is
not visible above trace level and the prepare flow continues as if successful.
Update the catch block in applySPMPackages to surface the failure with at least
this.$logger.warn (instead of only this.$logger.trace), preserving the error
details from resolveSPMDependencies so the user sees that Swift Package
resolution failed. Keep the change localized to applySPMPackages and the
resolveSPMDependencies call path.

---

Nitpick comments:
In `@lib/services/ios/xcodebuild-command-service.ts`:
- Around line 16-28: The executeCommand method in XcodebuildCommandService is
using an inline options object that duplicates the public
IXcodebuildCommandOptions contract. Update the method signature to reference
IXcodebuildCommandOptions directly so the implementation stays aligned with the
shared type and avoids future drift; use the existing executeCommand symbol in
XcodebuildCommandService and the IXcodebuildCommandOptions interface from the
ios definitions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3559c352-439f-4dca-a6b2-5119d1edd462

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc5ba1 and 4f13072.

📒 Files selected for processing (5)
  • lib/definitions/ios.d.ts
  • lib/services/ios-project-service.ts
  • lib/services/ios/spm-service.ts
  • lib/services/ios/xcodebuild-command-service.ts
  • test/ios-project-service.ts

Comment thread lib/services/ios/spm-service.ts
@NathanWalker NathanWalker merged commit 1344dc2 into main Jun 26, 2026
1 check was pending
@NathanWalker NathanWalker deleted the feat/xcodebuild-progress branch June 26, 2026 01:42
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