Português (Portuguese)
Appearance
Português (Portuguese)
Appearance
As projects grow in size and complexity, working with the entire codebase at once can become inefficient. Tuist provides metadata tags as a way to organize targets into logical groups and focus on specific parts of your project during development.
Metadata tags are string labels that you can attach to targets in your project. They serve as markers that allow you to:
Tags are defined using the metadata property on targets and are stored as an array of strings.
You can add tags to any target in your project manifest:
import ProjectDescription
let project = Project(
name: "MyApp",
targets: [
.target(
name: "Authentication",
destinations: .iOS,
product: .framework,
bundleId: "com.example.authentication",
sources: ["Sources/**"],
metadata: .metadata(tags: ["feature:auth", "team:identity"])
),
.target(
name: "Payment",
destinations: .iOS,
product: .framework,
bundleId: "com.example.payment",
sources: ["Sources/**"],
metadata: .metadata(tags: ["feature:payment", "team:commerce"])
),
.target(
name: "App",
destinations: .iOS,
product: .app,
bundleId: "com.example.app",
sources: ["Sources/**"],
dependencies: [
.target(name: "Authentication"),
.target(name: "Payment")
]
)
]
)Once you've tagged your targets, you can use the tuist generate command to create a focused project that includes only specific targets:
Use the tag: prefix to generate a project with all targets matching a specific tag:
# Generate project with all authentication-related targets
tuist generate tag:feature:auth
# Generate project with all targets owned by the identity team
tuist generate tag:team:identityYou can also focus on specific targets by name:
# Generate project with the Authentication target
tuist generate AuthenticationWhen you focus on targets:
This means you get a smaller, more manageable workspace that contains only what you need to work on your feature.
While you can use any string as a tag, following a consistent naming convention helps keep your tags organized:
// Organize by feature
metadata: .metadata(tags: ["feature:authentication", "feature:payment"])
// Organize by team ownership
metadata: .metadata(tags: ["team:identity", "team:commerce"])
// Organize by architectural layer
metadata: .metadata(tags: ["layer:ui", "layer:business", "layer:data"])
// Organize by platform
metadata: .metadata(tags: ["platform:ios", "platform:macos"])
// Combine multiple dimensions
metadata: .metadata(tags: ["feature:auth", "team:identity", "layer:ui"])Using prefixes like feature:, team:, or layer: makes it easier to understand the purpose of each tag and avoid naming conflicts.
You can leverage
project description helpers to standardize how tags are applied across your project:// Tuist/ProjectDescriptionHelpers/Project+Templates.swift
import ProjectDescription
extension Target {
public static func feature(
name: String,
team: String,
dependencies: [TargetDependency] = []
) -> Target {
.target(
name: name,
destinations: .iOS,
product: .framework,
bundleId: "com.example.\(name.lowercased())",
sources: ["Sources/**"],
dependencies: dependencies,
metadata: .metadata(tags: [
"feature:\(name.lowercased())",
"team:\(team.lowercased())"
])
)
}
}Then use it in your manifests:
import ProjectDescription
import ProjectDescriptionHelpers
let project = Project(
name: "Features",
targets: [
.feature(name: "Authentication", team: "Identity"),
.feature(name: "Payment", team: "Commerce"),
]
)By focusing on specific parts of your project, you can:
Tags provide a flexible way to organize your codebase:
Metadata tags work seamlessly with
Tuist's caching features:# Cache all targets
tuist cache
# Focus on targets with a specific tag and use cached dependencies
tuist generate tag:feature:payment