Skip to content

scaffold-ios: missing XCLocalSwiftPackageReference makes first build fail (Missing package product) #502

Description

@farazbukhari98

Summary

scaffold-ios generates an Xcode project whose app target declares a dependency on the bundled local Swift package product (<Name>Feature), but the generated project.pbxproj contains no XCLocalSwiftPackageReference. The first build fails with Missing package product.

Environment

  • xcodebuildmcp 2.6.0 (brew, getsentry tap)
  • Xcode 26.4 (Build 17E192)
  • macOS 26.4.1

Reproduction

  1. Scaffold a project:
xcodebuildmcp project-scaffolding scaffold-ios --project-name SmokeTest --output-path /tmp/smoke --bundle-identifier com.example.smoke
  1. Build for the simulator:
xcodebuildmcp simulator build-and-run --workspace-path /tmp/smoke/SmokeTest.xcworkspace --scheme SmokeTest --simulator-name "iPhone 17 Pro"

Expected

Build succeeds. The template's architecture (app shell + local SmokeTestPackage with a SmokeTestFeature product) is the documented intent of the scaffold.

Actual

Compiler Errors (1):
  ✗ Missing package product 'SmokeTestFeature' (in target 'SmokeTest' from project 'SmokeTest')
    /tmp/smoke/SmokeTest.xcodeproj
❌ Build failed.

Diagnosis

The generated project.pbxproj contains:

  • XCSwiftPackageProductDependency objects for SmokeTestFeature without a package attribute
  • no XCLocalSwiftPackageReference section at all
  • packageProductDependencies on both the app and UI-test targets, but no packageReferences

The workspace (SmokeTest.xcworkspace) references SmokeTestPackage only as a group: FileRef, which does not make Xcode resolve it as a package. With no package reference, Xcode cannot resolve the product.

Fix (verified on 2.6.0)

  1. Add an XCLocalSwiftPackageReference object with relativePath = SmokeTestPackage.
  2. Add package = <ref-id> to each XCSwiftPackageProductDependency.
  3. Add packageReferences = (<ref-id>) to each target that lists packageProductDependencies.

After this change the same build succeeds end to end (build, launch, tests).

Related

The same scaffold also generates a scheme with a dangling TestPlanReference (see the separate issue about the test plan file).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions