Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion Sources/XcodeGraph/PackageInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public struct PackageInfo: Equatable, Hashable {
/// The targets declared in the manifest.
public let targets: [Target]

/// The traits the package supports
public let traits: [PackageTrait]?

/// The declared platforms in the manifest.
public let platforms: [Platform]

Expand Down Expand Up @@ -46,6 +49,7 @@ public struct PackageInfo: Equatable, Hashable {
name: String,
products: [Product],
targets: [Target],
traits: [PackageTrait]?,
platforms: [Platform],
cLanguageStandard: String?,
cxxLanguageStandard: String?,
Expand All @@ -55,6 +59,7 @@ public struct PackageInfo: Equatable, Hashable {
self.name = name
self.products = products
self.targets = targets
self.traits = traits
self.platforms = platforms
self.cLanguageStandard = cLanguageStandard
self.cxxLanguageStandard = cxxLanguageStandard
Expand Down Expand Up @@ -588,7 +593,8 @@ extension PackageInfo: Codable {
}

private enum CodingKeys: String, CodingKey {
case name, products, targets, platforms, cLanguageStandard, cxxLanguageStandard, swiftLanguageVersions, toolsVersion
case name, products, targets, platforms, cLanguageStandard, cxxLanguageStandard, swiftLanguageVersions, toolsVersion,
traits
}

public init(from decoder: Decoder) throws {
Expand All @@ -615,6 +621,7 @@ extension PackageInfo: Codable {
)
}
self.toolsVersion = toolsVersion
traits = try values.decodeIfPresent([PackageTrait].self, forKey: .traits)
}

public func encode(to encoder: any Encoder) throws {
Expand All @@ -623,6 +630,7 @@ extension PackageInfo: Codable {
try container.encode(products, forKey: .products)
try container.encode(targets, forKey: .targets)
try container.encode(platforms, forKey: .platforms)
try container.encode(traits, forKey: .traits)
try container.encodeIfPresent(cLanguageStandard, forKey: .cLanguageStandard)
try container.encodeIfPresent(cxxLanguageStandard, forKey: .cxxLanguageStandard)
try container.encodeIfPresent(swiftLanguageVersions, forKey: .swiftLanguageVersions)
Expand Down Expand Up @@ -795,6 +803,7 @@ extension PackageInfo.Target.TargetType {
name: String = "Package",
products: [Product] = [],
targets: [Target] = [],
traits: [PackageTrait] = [],
platforms: [Platform] = [],
cLanguageStandard: String? = nil,
cxxLanguageStandard: String? = nil,
Expand All @@ -805,6 +814,7 @@ extension PackageInfo.Target.TargetType {
name: name,
products: products,
targets: targets,
traits: traits,
platforms: platforms,
cLanguageStandard: cLanguageStandard,
cxxLanguageStandard: cxxLanguageStandard,
Expand Down
10 changes: 10 additions & 0 deletions Sources/XcodeGraph/PackageTrait.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public struct PackageTrait: Equatable, Hashable, Codable {
/// The list of traits that are enabled by default.
public let enabledTraits: [String]

/// The name of the trait. When a trait just includes enabled traits, this name takes the value of "default"
public let name: String

/// Trait description
public let description: String?
}
7 changes: 7 additions & 0 deletions Tests/XcodeGraphTests/Models/PackageInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ struct PackageInfoTests {
checksum: nil
),
],
traits: [
PackageTrait(
enabledTraits: ["Tuist"],
name: "Tuist",
description: "This is the default Tuist trait"
),
],
platforms: [
PackageInfo.Platform(platformName: "iOS", version: "17.2", options: []),
],
Expand Down