Understanding Workspaces
An Xcode workspace is a container that groups multiple projects, allowing them to work together while maintaining independence.Without Workspace
Single project, all targets in one
.xcodeprojWith Workspace
Multiple projects organized in one
.xcworkspaceWhen to Use Workspaces
- Single Project
- Multiple Projects
Use a single
Project.swift when:- You have a simple app structure
- All targets are closely related
- Team is small (< 5 developers)
- Build times are acceptable
Tuist automatically creates a workspace for single projects - no
Workspace.swift needed!Creating a Workspace
Define a workspace inWorkspace.swift:
Workspace Structure Patterns
- Feature-Based
- Layer-Based
- Micro-Features
- Monorepo
Organize by product features:
Workspace.swift
Cross-Project Dependencies
Link targets across projects in the workspace:Workspace Schemes
Create schemes that span multiple projects:Workspace.swift
Additional Files
Include documentation and configuration files in the workspace:Workspace Generation Options
Customize workspace behavior:Best Practices
Keep Dependencies Unidirectional
Keep Dependencies Unidirectional
Ensure dependencies flow in one direction:Avoid:Use protocols/interfaces to invert dependencies when needed:
Use Focused Workspaces for Large Teams
Use Focused Workspaces for Large Teams
Create team-specific workspaces:
Optimize Build Times
Optimize Build Times
Structure projects to minimize rebuilds:
- Small, focused projects - Changes affect fewer targets
- Static frameworks - Faster linking than dynamic
- Explicit dependencies - Avoid unnecessary rebuilds
Document Your Architecture
Document Your Architecture
Include architecture documentation in the workspace:
Visualizing Your Workspace
Tuist can generate a visual graph of your workspace:Migration Strategies
- Monolith to Modular
- Existing Workspace
Gradually extract features from a monolithic app:
1
Start with Core
Extract shared utilities first:
2
Extract Features
Move features one at a time:
3
Continue Extraction
Gradually move all features:
Example: Real-World Workspace
Here’s a complete example of a production workspace:Next Steps
Manifests
Deep dive into manifest file structure
Generated Projects
Understand project generation
Architecture
Learn about Tuist’s architecture
Dependencies
Managing external dependencies