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
22 changes: 18 additions & 4 deletions PIF/Sources/PIFSupport/PIF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,22 +378,36 @@ public enum PIF {

/// Represents a dependency on another target (identified by its PIF GUID).
public struct TargetDependency: Decodable {
/// Name of dependency
public let name: String

/// Identifier of depended-upon target.
public let targetGUID: String
public let targetGUID: String?

/// The platform filters for this target dependency.
public let platformFilters: [PlatformFilter]

private enum CodingKeys: CodingKey {
case guid, platformFilters
case name, guid, platformFilters
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

targetGUID = try container.decode(String.self, forKey: .guid)
name = try container.decodeIfPresent(String.self, forKey: .name) ?? "Unknown"
targetGUID = try container.decodeIfPresent(String.self, forKey: .guid)

if targetGUID == nil {
logger.info(" ------------------------------------------------------------------------------------------")
logger.info(" Error: dependency \(name) is missing a guid and will not be resolved!\n")
logger.info(" For more context rerun with --log-level=trace.")
logger.info(" Be aware the this may generate a LOT of output.")
logger.info(" This is an error in your project metadata you may want to report this to Apple.")
logger.info(" ------------------------------------------------------------------------------------------")
}

platformFilters = try container.decodeIfPresent([PlatformFilter].self, forKey: .platformFilters) ?? []
logger.trace("---> Decoded TargetDependency: \(targetGUID)")
logger.trace("---> Decoded TargetDependency: \(name) \(targetGUID ?? "<nil>")")
}
}

Expand Down
21 changes: 16 additions & 5 deletions Sources/GenIR/PIFCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,17 @@ struct PIFDependencyProvider: DependencyProviding {

let productTargetDependencies = cache.target(guid: product.guid)?
.dependencies
.filter { $0.targetGUID.starts(with: targetToken) }
.compactMap { dependency -> PIF.TargetDependency? in
guard let guid = dependency.targetGUID, guid.starts(with: targetToken) else { return nil }
return dependency
}
?? []

let productUnderlyingTargets = productTargetDependencies
.filter { $0.targetGUID.dropFirst(targetToken.count) == productName }
.filter { dependency in
guard let guid = dependency.targetGUID else { return false }
return guid.dropFirst(targetToken.count) == productName
}

if productUnderlyingTargets.isEmpty && !productTargetDependencies.isEmpty {
// We likely have a stub target here (i.e. a precompiled framework)
Expand All @@ -217,15 +223,20 @@ struct PIFDependencyProvider: DependencyProviding {
return productTargetDependencies.first?.targetGUID
}

GenIRLogger.logger.debug("\(packageProductGUID) resolves to \(target.targetGUID)")
return target.targetGUID
guard let targetGUID = target.targetGUID else {
GenIRLogger.logger.debug("\(packageProductGUID) resolves to a target with nil GUID")
return nil
}

GenIRLogger.logger.debug("\(packageProductGUID) resolves to \(targetGUID)")
return targetGUID
}

func dependencies(for value: Target) -> [Target] {
// Direct dependencies
let dependencyTargetGUIDs = cache.target(guid: value.guid)?
.dependencies
.map { $0.targetGUID }
.compactMap { $0.targetGUID }
.compactMap { resolveSwiftPackage($0) }
?? []

Expand Down
5 changes: 3 additions & 2 deletions Sources/GenIR/Versions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// Created by Thomas Hedderwick on 12/09/2022.
//
// History:
// 2025-nn-nn - 1.0.1 -- Use info logging to allow user to monitor progress.
// 2026-nn-nn - 1.0.2 -- SSAST-11722 don't fail on TargetDependency decode failure.
// 2026-01-08 - 1.0.1 -- Use info logging to allow user to monitor progress.
// 2025-12-01 - 1.0.0 -- Don't chase through Dynamic Dependencies
// 2025-09-19 - 0.5.4 -- Update release doc; warn multiple builds; capture debug data
// 2025-04-18 - 0.5.3 -- PIF Tracing; log unique compiler commands
Expand All @@ -15,5 +16,5 @@
import Foundation

enum Versions {
static let version = "1.0.1"
static let version = "1.0.2"
}
Loading