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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ struct PBXFrameworksBuildPhaseMapper: PBXFrameworksBuildPhaseMapping {
xcodeProj: XcodeProj
) throws -> TargetDependency {
let fileRef = try buildFile.file.throwing(PBXFrameworksBuildPhaseMappingError.missingFileReference)
switch fileRef.sourceTree {
case .buildProductsDir:
guard let path = fileRef.path else { break }
let name = path.replacingOccurrences(of: ".framework", with: "")
return .target(
name: name,
status: .required,
condition: nil
)
default:
break
}
let filePathString = try fileRef.fullPath(sourceRoot: xcodeProj.srcPathString)
.throwing(PBXFrameworksBuildPhaseMappingError.missingFilePath(name: fileRef.name))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Path
import Testing
import XcodeGraph
import XcodeProj

@testable import XcodeGraphMapper

@Suite
Expand All @@ -18,9 +20,20 @@ struct PBXFrameworksBuildPhaseMapperTests {
)
.add(to: pbxProj)
.addToMainGroup(in: pbxProj)

let frameworkBuildFile = PBXBuildFile(file: frameworkRef).add(to: pbxProj)
let frameworksPhase = PBXFrameworksBuildPhase(files: [frameworkBuildFile]).add(to: pbxProj)

let targetFrameworkRef = PBXFileReference(
sourceTree: .buildProductsDir,
path: "Target.framework"
)
let targetFrameworkBuildFile = PBXBuildFile(file: targetFrameworkRef).add(to: pbxProj)

let frameworksPhase = PBXFrameworksBuildPhase(
files: [
frameworkBuildFile,
targetFrameworkBuildFile,
]
).add(to: pbxProj)

try PBXNativeTarget(
name: "App",
Expand All @@ -36,8 +49,20 @@ struct PBXFrameworksBuildPhaseMapperTests {
let frameworks = try mapper.map(frameworksPhase, xcodeProj: xcodeProj)

// Then
#expect(frameworks.count == 1)
let dependency = try #require(frameworks.first)
#expect(dependency.name == "MyFramework")
let frameworkPath = try AbsolutePath(validating: "/tmp/TestProject/Frameworks/MyFramework.framework")
#expect(
frameworks.sorted(by: { $0.name < $1.name }) == [
.framework(
path: frameworkPath,
status: .required,
condition: nil
),
.target(
name: "Target",
status: .required,
condition: nil
),
]
)
}
}
Loading