Skip to content

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
Contributor

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?)

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

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.
let relativePath = try RelativePath(validating: package.relativePath)
let path = sourceDirectory.appending(relativePath)
return .local(path: path)
return .local(path: path, groupPath: nil)
Copy link

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
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.

I left some minor comments.

let relativePath = try RelativePath(validating: package.relativePath)
let path = sourceDirectory.appending(relativePath)
return .local(path: path)
return .local(path: path, groupPath: nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we get groupPath from XCLocalSwiftPackageReference?

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
Contributor

Choose a reason for hiding this comment

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

Same here, can't we get groupPath?

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