Skip to content

Add local packages structure logic #232

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

layoutIfNeeded
Copy link

@pepicrft @fortmarek Hello! 👋

When you have a moment, could you please review this PR? I’m aiming to add support for structured folders in local packages (per the discussion here: https://community.tuist.dev/t/how-to-generate-and-keep-structured-folders-local-packages/245), but I’ve hit a roadblock. I’d be grateful for any feedback or a merge. Thank you! 🙏

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Jun 19, 2025
@pepicrft pepicrft requested review from Copilot and fortmarek June 19, 2025 09:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for structured folders in local packages by updating the local package mapping logic across several components. The key changes include:

  • Updating the PBXProjectMapper to include an additional groupPath parameter when mapping local packages.
  • Modifying the XCPackageMapper to propagate the new groupPath parameter.
  • Adjusting the Package model and its extensions to accommodate the new structured folders design.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Sources/XcodeGraphMapper/Mappers/Project/PBXProjectMapper.swift Updated mapping of local packages with an added groupPath parameter.
Sources/XcodeGraphMapper/Mappers/Packages/XCPackageMapper.swift Modified return value of local package mapping to include groupPath.
Sources/XcodeGraphMapper/Extensions/Package+Extensions.swift Adjusted switch-case matching to destructure the new parameter while ignoring it.
Sources/XcodeGraph/Models/Package.swift Updated the Package enum to support an optional groupPath.
Comments suppressed due to low confidence (2)

Sources/XcodeGraphMapper/Extensions/Package+Extensions.swift:9

  • [nitpick] Document the decision to disregard the groupPath parameter in the conversion to a path string, so that future maintainers understand this intentional omission.
        case let .local(path, _):

Sources/XcodeGraph/Models/Package.swift:6

  • Ensure that all consumers of the Package API are updated to correctly handle the new optional groupPath parameter.
    case local(path: AbsolutePath, groupPath: String?)

@@ -97,7 +97,7 @@ struct PBXProjectMapper: PBXProjectMapping {
}
let localPackages = try pbxProject.localPackages.compactMap {
try packageMapper.map(package: $0, sourceDirectory: sourceDirectory)
} + localPackagePaths.map { .local(path: $0) }
} + localPackagePaths.map { .local(path: $0, groupPath: nil) }
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

All local package mappings use nil for groupPath. If structured folders are intended, consider retrieving and passing the appropriate group path when available to improve maintainability.

Copilot uses AI. Check for mistakes.

@@ -48,7 +48,7 @@ struct XCPackageMapper: XCPackageMapping {
func map(package: XCLocalSwiftPackageReference, sourceDirectory: AbsolutePath) throws -> Package {
let relativePath = try RelativePath(validating: package.relativePath)
let path = sourceDirectory.appending(relativePath)
return .local(path: path)
return .local(path: path, groupPath: nil)
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

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

Consider propagating groupPath information if available to support structured folder logic, rather than defaulting to nil.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

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

@rishatyakushev thanks for doing this. I'd keep this one open until the counterpart in tuist/tuist is approved :)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants