Skip to content

Commit 256582e

Browse files
committed
Set explicit file types in PIF for binary artifacts
1 parent 9653927 commit 256582e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ extension PackagePIFProjectBuilder {
227227
case macro
228228
}
229229

230+
static func createBinaryModuleFileReference(_ binaryModule: BinaryModule, id: ProjectModel.GUID) -> FileReference {
231+
let fileTypeIdentifier: String?
232+
switch binaryModule.kind {
233+
case .artifactsArchive:
234+
fileTypeIdentifier = "wrapper.artifactbundle"
235+
case .xcframework:
236+
fileTypeIdentifier = "wrapper.xcframework"
237+
case .unknown:
238+
fileTypeIdentifier = nil
239+
}
240+
return FileReference(id: id, path: (binaryModule.artifactPath.pathString), fileType: fileTypeIdentifier)
241+
}
242+
230243
/// Constructs a *PIF target* for building a *module* as a particular type.
231244
/// An optional target identifier suffix is passed when building variants of a target.
232245
@discardableResult
@@ -651,7 +664,7 @@ extension PackagePIFProjectBuilder {
651664
break
652665
}
653666
let binaryReference = self.binaryGroup.addFileReference { id in
654-
FileReference(id: id, path: (binaryModule.artifactPath.pathString))
667+
return Self.createBinaryModuleFileReference(binaryModule, id: id)
655668
}
656669
if shouldLinkProduct {
657670
self.project[keyPath: sourceModuleTargetKeyPath].addLibrary { id in

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Products.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ extension PackagePIFProjectBuilder {
346346
break
347347
}
348348
let binaryFileRef = self.binaryGroup.addFileReference { id in
349-
FileReference(id: id, path: binaryModule.artifactPath.pathString)
349+
Self.createBinaryModuleFileReference(binaryModule, id: id)
350350
}
351351
let toolsVersion = self.package.manifest.toolsVersion
352352
self.project[keyPath: mainModuleTargetKeyPath].addLibrary { id in

0 commit comments

Comments
 (0)