Skip to content

Extend Swift file updater to support xcode swiftpm dependency update#14394

Merged
AbhishekBhaskar merged 9 commits into
mainfrom
swift-xcode-spm-file-updater
Mar 16, 2026
Merged

Extend Swift file updater to support xcode swiftpm dependency update#14394
AbhishekBhaskar merged 9 commits into
mainfrom
swift-xcode-spm-file-updater

Conversation

@AbhishekBhaskar
Copy link
Copy Markdown
Contributor

@AbhishekBhaskar AbhishekBhaskar commented Mar 9, 2026

What are you trying to accomplish?

This PR adds support for updating Package.resolved files in Xcode-managed SwiftPM projects that don't have a Package.swift manifest, enabling Dependabot to generate dependency update PRs for .xcodeproj-only Swift projects.

Changes:
New file: swift/lib/dependabot/swift/file_updater/xcode_lockfile_updater.rb

  • Updates Package.resolved files in-place without running Swift CLI
  • Preserves original schema version (v1/v2/v3) format
  • Matches dependencies by identity or normalized URL
  • Only updates resolved files relevant to each dependency (based on .xcodeproj directory)

Modified: file_updater.rb

  • Added xcode_spm_mode? detection when experiment is enabled and no Package.swift exists
  • Added updated_xcode_spm_files method for Xcode-managed updates
  • Updated check_required_files to accept Xcode Package.resolved files

Modified:[update_checker.rb

  • Handle nil preferred_resolvable_version for revision-only or branch-pinned dependencies

Modified: metadata_finder.rb

  • Handle "default" source type by inferring source from dependency name

Anything you want to highlight for special attention from reviewers?

Behaviour:

  • Behind enable_swift_xcode_spm experiment flag
  • Updates correct Package.resolved files with minimal changes
  • Supports multiple Xcode projects in single repo
  • Produces clean JSON diffs matching Xcode's formatting

How will you know you've accomplished your goal?

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@AbhishekBhaskar AbhishekBhaskar self-assigned this Mar 9, 2026
@github-actions github-actions Bot added the L: swift Swift packages label Mar 9, 2026
Base automatically changed from swift-xcode-spm-file-parser to main March 10, 2026 11:27
@AbhishekBhaskar AbhishekBhaskar changed the title [WIP] Extend Swift file updater to support xcode swiftpm dependency update Extend Swift file updater to support xcode swiftpm dependency update Mar 16, 2026
@AbhishekBhaskar AbhishekBhaskar marked this pull request as ready for review March 16, 2026 05:56
@AbhishekBhaskar AbhishekBhaskar requested a review from a team as a code owner March 16, 2026 05:56
Copilot AI review requested due to automatic review settings March 16, 2026 05:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds experimental support in the Swift ecosystem for updating Xcode-managed SwiftPM projects that only contain .xcodeproj files (no Package.swift) by editing Xcode Package.resolved files in-place, enabling Dependabot PRs for these repos.

Changes:

  • Introduces an Xcode-specific Package.resolved updater that preserves schema versions (v1/v2/v3) and formatting.
  • Adds xcode_spm_mode? branching in the Swift FileUpdater to update Xcode lockfiles without invoking the Swift CLI.
  • Improves Swift UpdateChecker and MetadataFinder handling for revision/branch pins and dependencies without explicit source type.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
swift/spec/dependabot/swift/file_updater_spec.rb Adds integration coverage for Xcode SPM mode updating the correct Package.resolved file(s).
swift/spec/dependabot/swift/file_updater/xcode_lockfile_updater_spec.rb Adds unit tests for updating v1/v2/v3 resolved schemas and error cases.
swift/lib/dependabot/swift/update_checker.rb Avoids T.must on nil preferred_resolvable_version for revision/branch-pinned deps.
swift/lib/dependabot/swift/metadata_finder.rb Infers source from dependency name when source_type is default/nil.
swift/lib/dependabot/swift/file_updater/xcode_lockfile_updater.rb Implements in-place JSON update logic for Xcode Package.resolved.
swift/lib/dependabot/swift/file_updater.rb Adds experiment-gated Xcode mode and updates required-files logic accordingly.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread swift/lib/dependabot/swift/file_updater/xcode_lockfile_updater.rb
markhallen
markhallen previously approved these changes Mar 16, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@AbhishekBhaskar AbhishekBhaskar merged commit 50ff170 into main Mar 16, 2026
86 checks passed
@AbhishekBhaskar AbhishekBhaskar deleted the swift-xcode-spm-file-updater branch March 16, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: swift Swift packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants