Skip to content

run-ios duplicates Package.resolved in SPM projects #2665

Open
@NedStar72

Description

@NedStar72

Environment

System:
  OS: macOS 15.3.2
  CPU: (12) arm64 Apple M4 Pro
  Memory: 110.50 MB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.5
    path: ~/.nvm/versions/node/v18.20.5/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v18.20.5/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v18.20.5/bin/npm
  Watchman:
    version: 2025.04.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/nedstar/.rvm/gems/ruby-3.3.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.25659.59.2432.13423653
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 3.3.6
    path: /Users/nedstar/.rvm/rubies/ruby-3.3.6/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.2
    wanted: 0.79.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Description

In packages/cli-platform-apple/src/tools/getInfo.ts:71, the CLI invokes:

await execXcodeBuild([
  '-list',
  '-json',
  '-project',
  projectPath,
]);

Calling xcodebuild -list -json -project "<Project>.xcodeproj" causes Xcode to automatically re-resolve Swift Package Manager dependencies and write a new Package.resolved into:

ios/<Project>.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

When dependencies are already locked at the workspace level (<Project>.xcworkspace/xcshareddata/swiftpm/Package.resolved), this:

  • Duplicates the lockfile under the .xcodeproj workspace
  • Pollutes the repo with untracked files
  • Violates the expectation that -list -json is a read-only metadata query

All of this occurs despite the CLI’s intent being only to fetch schemes, targets, and configurations.

Reproducible Demo

  1. In a React Native iOS project with SPM enabled, open the workspace once in Xcode so that
    ios/<Project>.xcworkspace/xcshareddata/swiftpm/Package.resolved exists.

  2. Delete that shared lockfile:

    rm ios/<Project>.xcworkspace/xcshareddata/swiftpm/Package.resolved
  3. Change into the ios/ directory and run:

    xcodebuild -list -json -project "<Project>.xcodeproj"
  4. Verify that a new file was created at:

    ios/<Project>.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
    

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions