Skip to content

Commit

Permalink
Attempt to resolve Objective-C dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmxav committed Jul 9, 2024
1 parent e7354b2 commit e86e5c5
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Sources/GenIR/PIFCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,29 @@ class PIFCache {
.flatMap { fileReferences(for: $0) }
.filter { $0.fileType == "wrapper.framework" }

// Now, stupidly, we have to do a name lookup on the path and use that to look up a target
let frameworks = targets
.compactMap { $0 as? PIF.Target }
.filter { $0.productType == .framework }

let frameworkGUIDs = frameworks
.reduce(into: [String: PIF.Target]()) { partial, target in
let key = target.productName.isEmpty ? target.guid : target.productName
partial[key] = target
partial[target.guid] = target
}

return frameworkFileReferences
// Map product names to targets
let frameworkProducts = frameworks
.reduce(into: [String: PIF.Target]()) { partial, target in
if !target.productName.isEmpty {
partial[target.productName] = target
}
}

let frameworkReferenceTargets = frameworkFileReferences
.reduce(into: [PIF.GUID: PIF.Target]()) { partial, fileReference in
// Use the _file reference_ GUID as the key here - we're looking up frameworks by their file reference and not target GUID!
partial[fileReference.guid] = frameworks[fileReference.path]
partial[fileReference.guid] = frameworkProducts[fileReference.path]
}

return frameworkGUIDs.merging(frameworkReferenceTargets) { _, new in new }
}()
}

Expand Down Expand Up @@ -225,11 +234,10 @@ struct PIFDependencyProvider: DependencyProviding {
let frameworkGUIDs = cache.target(guid: value.guid)?
.buildPhases
.flatMap { $0.buildFiles }
// .compactMap { $0 as? PIF.FrameworksBuildPhase }
.compactMap {
switch $0.reference {
case let .file(guid): return guid
case .target: return nil
case let .file(guid): return cache.frameworks[guid]?.guid
case .target(let guid): return guid
}
}
.compactMap { cache.frameworks[$0]?.guid }
Expand Down

0 comments on commit e86e5c5

Please sign in to comment.