Skip to content

Some PIF delegate fixes for Swift Build #8573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
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
3 changes: 2 additions & 1 deletion Sources/SwiftBuildSupport/PIFBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelega
[]
}

func addCustomTargets(pifProject: SwiftBuild.ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct] {
func addCustomTargets(pifProject: inout SwiftBuild.ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct] {
return []
}

Expand All @@ -292,6 +292,7 @@ fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelega

func configureLibraryProduct(
product: PackageModel.Product,
project: inout ProjectModel.Project,
target: WritableKeyPath<ProjectModel.Project, ProjectModel.Target>,
additionalFiles: WritableKeyPath<ProjectModel.Group, ProjectModel.Group>
) {
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftBuildSupport/PackagePIFBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public final class PackagePIFBuilder {
func customSDKOptions(forPlatform: PackageModel.Platform) -> [String]

/// Create additional custom PIF targets after all targets have been built.
func addCustomTargets(pifProject: ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct]
func addCustomTargets(pifProject: inout ProjectModel.Project) throws -> [PackagePIFBuilder.ModuleOrProduct]

/// Should we suppresses the specific product dependency, updating the provided build settings if necessary?
/// The specified product may be in the same package or a different one.
Expand All @@ -139,6 +139,7 @@ public final class PackagePIFBuilder {
/// Provides additional configuration and files for the specified library product.
func configureLibraryProduct(
product: PackageModel.Product,
project: inout ProjectModel.Project,
target: WritableKeyPath<ProjectModel.Project, ProjectModel.Target>,
additionalFiles: WritableKeyPath<ProjectModel.Group, ProjectModel.Group>
)
Expand Down Expand Up @@ -467,7 +468,7 @@ public final class PackagePIFBuilder {
}
}

let customModulesAndProducts = try delegate.addCustomTargets(pifProject: projectBuilder.project)
let customModulesAndProducts = try delegate.addCustomTargets(pifProject: &projectBuilder.project)
projectBuilder.builtModulesAndProducts.append(contentsOf: customModulesAndProducts)

self._pifProject = projectBuilder.project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ extension PackagePIFProjectBuilder {
// Additional configuration and files for this library product.
pifBuilder.delegate.configureLibraryProduct(
product: product.underlying,
project: &self.project,
target: librayUmbrellaTargetKeyPath,
additionalFiles: additionalFilesGroupKeyPath
)
Expand Down