Summary
Add .xcworkspace support to XcodeBuildSystem, extending the existing .xcodeproj support added in #16.
Motivation
Xcode workspaces are the standard way to manage multi-project setups:
- CocoaPods projects (Pods.xcodeproj + App.xcodeproj wrapped in a workspace)
- SPM-integrated Xcode projects (Xcode auto-generates a workspace)
- Multi-project apps (e.g., app + frameworks + extensions)
When a .xcworkspace exists alongside a .xcodeproj, Xcode itself prefers the workspace. PreviewsMCP should do the same.
Proposed Changes
-
Detection: In XcodeBuildSystem.detect(for:), check for .xcworkspace before .xcodeproj. If both exist, prefer the workspace.
-
Build commands: Use -workspace <path> -scheme <scheme> instead of -project <path> -scheme <scheme>. The rest of the pipeline (build settings parsing, OutputFileMap, -F flags) is identical.
-
Scheme discovery: xcodebuild -workspace <path> -list -json works the same as -project.
Non-Goals
- No need to parse workspace contents (
.xcworkspacedata) — xcodebuild handles project resolution internally
- No CocoaPods-specific logic — the workspace abstraction handles this transparently
Context
.xcodeproj support was added in #16/#32. The current XcodeBuildSystem stores an xcodeproj: URL — this would become a more general projectOrWorkspace: URL with a flag or enum indicating which xcodebuild flag to use (-project vs -workspace).
Summary
Add
.xcworkspacesupport toXcodeBuildSystem, extending the existing.xcodeprojsupport added in #16.Motivation
Xcode workspaces are the standard way to manage multi-project setups:
When a
.xcworkspaceexists alongside a.xcodeproj, Xcode itself prefers the workspace. PreviewsMCP should do the same.Proposed Changes
Detection: In
XcodeBuildSystem.detect(for:), check for.xcworkspacebefore.xcodeproj. If both exist, prefer the workspace.Build commands: Use
-workspace <path> -scheme <scheme>instead of-project <path> -scheme <scheme>. The rest of the pipeline (build settings parsing, OutputFileMap,-Fflags) is identical.Scheme discovery:
xcodebuild -workspace <path> -list -jsonworks the same as-project.Non-Goals
.xcworkspacedata) — xcodebuild handles project resolution internallyContext
.xcodeprojsupport was added in #16/#32. The currentXcodeBuildSystemstores anxcodeproj: URL— this would become a more generalprojectOrWorkspace: URLwith a flag or enum indicating which xcodebuild flag to use (-projectvs-workspace).