Skip to content
Closed
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
19 changes: 17 additions & 2 deletions PIF/Sources/PIFSupport/PIF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public enum PIF {
case dataReadingFailure(String)
}

struct FailableDecodable<T: Decodable>: Decodable {
let value: T?

init(from decoder: Decoder) throws {
do {
value = try T(from: decoder)
} catch {
logger.error("Failed to decode \(T.self): \(error)")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I worry this isn't enough of a warning that we're failing to determine a dependency. We should be pretty aggressive here, without dependencies (or a very stern warning) you may think you're scanning everything, when we're failing to make a link between two dependencies

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was unsure also whether to even add this change. It looked to me like it might be a corrupt PIF but I wasn't sure. I did ask the customer to try with a clean PIF and if it still failed to try and clean up the dependency in Xcode (see https://veracode.atlassian.net/browse/ENG-61598?focusedCommentId=1328164). So, I'll just drop this branch and leave the failure for now.

value = nil
}
}
}

/// The top-level PIF object.
public struct TopLevelObject: Decodable {
public let workspace: PIF.Workspace
Expand Down Expand Up @@ -451,7 +464,8 @@ public enum PIF {
return try BuildPhase.decode(container: &buildPhasesContainer, type: type)
}

let dependencies = try container.decode([TargetDependency].self, forKey: .dependencies)
let rawdependencies = try container.decode([FailableDecodable<TargetDependency>].self, forKey: .dependencies)
let dependencies = rawdependencies.compactMap { $0.value }
let impartedBuildProperties = try container.decodeIfPresent(BuildSettings.self, forKey: .impartedBuildProperties)
logger.trace("---> Decoded BaseTarget: guid \(guid) name \(name)")

Expand Down Expand Up @@ -515,7 +529,8 @@ public enum PIF {
let guid = try container.decode(GUID.self, forKey: .guid)
let name = try container.decode(String.self, forKey: .name)
let buildConfigurations = try container.decode([BuildConfiguration].self, forKey: .buildConfigurations)
let dependencies = try container.decode([TargetDependency].self, forKey: .dependencies)
let rawdependencies = try container.decode([FailableDecodable<TargetDependency>].self, forKey: .dependencies)
let dependencies = rawdependencies.compactMap { $0.value }
let type = try container.decode(String.self, forKey: .type)

let buildPhases: [BuildPhase]
Expand Down
2 changes: 1 addition & 1 deletion Sources/GenIR/GenIR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct DebuggingOptions: ParsableArguments {
@Option(help: ArgumentHelp("Specifiy a logging level. The --debug flag will override this", visibility: .hidden))
var logLevel: LogLevelArgument?

@Flag(help: ArgumentHelp("Path to save a zip file containing debug data.", visibility: .hidden))
@Flag(help: ArgumentHelp("If true, add captured debug data to the xcarchive.", visibility: .hidden))
var capture: Bool = false
}

Expand Down
Loading