Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Sources/XcodeGraph/Models/Metadata/TargetMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,39 @@ public struct TargetMetadata: Codable, Equatable, Sendable {
/// Some Tuist features can leverage that information for doing things like filtering.
public var tags: Set<String>

/// Whether the target redundant dependencies should be ignored during `tuist inspect redundant-import`
public var ignoreRedundantDependencies: Bool
Comment on lines +7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XcodeGraph models should contain attributes/metadata that's associated with the graph, not with how some Tuist features will behave because it couples the model with the tool that uses the graph. I'd recommend to move this to the Tuist.swift model in tuist/tuist:

let tuist = Tuist(inspect: .inspect(redundantDependencies: .redundantDependencies(disableTargets: []))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC Tuist can't import code from project description helpers, and it would make it very cumbersome to maintain.

What I want to do is:

  • I define a feature let featureX = Feature(name: "X", interface: …, implementation: …)
  • Then I do featureX.targets() to get the list of targets according to the configuration, but I want (for example) the test target to be marked with ignoreRedundantDependencies, which is very easy to do if it's part of the Target init

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you share more about your setup? I believe this is part of your wrapper, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danieleformichelli let's continue the conversation here. I misunderstood the second part. In that case I recommend that you apply a tag to the target, which we already have an API for, and then in the Tuist.swift you can use the tag to match targets:

let tuist = Tuist(
  inspect: .inspect(
    redundantDependencies: .redundantDeps(ignoreTagsMatching: ["tag"]) // or something along these lines
  )
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! 🙏


@available(*, deprecated, renamed: "metadata(tags:)", message: "Use the static 'metadata' initializer instead")
public init(
tags: Set<String>
) {
self.tags = tags
self.init(tags: tags, isLocal: false, ignoreRedundantDependencies: false)
}

init(tags: Set<String>, isLocal _: Bool) {
init(tags: Set<String>, isLocal _: Bool, ignoreRedundantDependencies: Bool) {
self.tags = tags
self.ignoreRedundantDependencies = ignoreRedundantDependencies
}

public static func metadata(tags: Set<String> = Set(), isLocal: Bool = true) -> TargetMetadata {
self.init(tags: tags, isLocal: isLocal)
public static func metadata(
tags: Set<String> = Set(),
isLocal: Bool = true,
ignoreRedundantDependencies: Bool = false
) -> TargetMetadata {
self.init(tags: tags, isLocal: isLocal, ignoreRedundantDependencies: ignoreRedundantDependencies)
}
}

#if DEBUG
extension TargetMetadata {
public static func test(
tags: Set<String> = []
tags: Set<String> = [],
ignoreRedundantDependencies: Bool = false
) -> TargetMetadata {
TargetMetadata.metadata(
tags: tags
tags: tags,
ignoreRedundantDependencies: ignoreRedundantDependencies
)
}
}
Expand Down