Fix SPM dependency linking and Xcode multi-scheme selection#73
Merged
Conversation
SPM: After swift build, archive each dependency target's .o files into lib<Dep>.a and pass -L <binPath> -l<Dep> so the bridge dylib can link against sibling targets and cross-package dependencies. SPM doesn't create static archives or emit autolink hints for library targets, so the build system has to stage them explicitly. Xcode: Add optional `scheme` parameter threaded from MCP tool schemas and CLI options through BuildSystemDetector into XcodeBuildSystem. When set, pickScheme() validates it against the project's scheme list. When unset, existing heuristics apply (single scheme auto-pick, then path-component matching). Ambiguous-target error now names the `scheme` parameter instead of suggesting `projectRoot`. Adds ToDoExtras (sibling target) and LocalDep (cross-package path dep) to the SPM example. The existing Tier 2 test now exercises dependency linking as a regression guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62f79f0 to
4fe1067
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #69 and #70.
SPM dependency linking (SPM build doesn't include package dependencies in build context #69): After
swift build, SPMBuildSystem now archives each dependency target's.ofiles intolib<Dep>.aand passes-L <binPath> -l<Dep>to the bridge compilation. SPM doesn't create static archives or emit autolink hints for library targets, so the build system stages them explicitly. Covers both sibling targets within the samePackage.swiftand cross-package dependencies resolved via.package(path:)or.package(url:).Xcode multi-scheme selection (Xcode projects/workspaces don't auto-pick a scheme when multiple are present #70): Adds an optional
schemeparameter topreview_start(MCP),--scheme(CLI run/snapshot), andBuildSystemDetector.detect(). When set,pickScheme()validates it against the project's scheme list and returns it (overriding heuristics). When unset, existing behavior is preserved (single-scheme auto-pick, path-component matching). The ambiguous-target error now names theschemeparameter and lists candidates. Also addsBuildSystemError.unknownSchemefor when an explicit scheme isn't found.Test plan
PreviewSessionBuildContextTests.spmLinksDependencyTargets— verifies-L,-lToDoExtras(sibling target), and-lLocalDep(cross-package) are in compiler flags, and-lToDo(consumer) is excludedPreviewSessionBuildContextTests.tier2Compile— end-to-end Tier 2 dylib compilation succeeds withimport ToDoExtrasandimport LocalDepin the source treeBuildSystemTests.pickSchemeHonorsRequested— explicit scheme overrides path-component heuristicBuildSystemTests.pickSchemeRejectsUnknownRequested— unknown scheme surfaces clear error with candidatesBuildSystemTests.pickSchemeRequestedWinsOverSingle— explicit mismatch throws even with one schemeBuildSystemTests.ambiguousTargetErrorMessage— error text mentionsschemeparameterBuildSystemTests.detectorPassesSchemeToXcode— scheme threads through BuildSystemDetector to XcodeBuildSystem🤖 Generated with Claude Code