tuist / XcodeProj

πŸ“ Read, update and write your Xcode projects

Home Page:https://xcodeproj.tuist.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Virtual group hierarchy path

markst opened this issue Β· comments

Context πŸ•΅οΈβ€β™€οΈ

Our project has been in development for over 10 years and has has very poor maintenance.
We wish to use XcodeProj to do a cleanup of the file system so that 900+ files are no in the root level.

What 🌱

PBXFileElement.fullPath returns the path to file in the filesystem, however we wish to fetch the 'virtual' path in the project hierarchy.

Proposal πŸŽ‰

Possibly can just be achieved by using an extension which generates the path based on parent group:

extension PBXFileElement {
    func virtualPath() -> String? {
        if let file = (parent as? PBXGroup)?.name {
            return (parent?.virtualPath() ?? "x") + "/" + (name ?? path ?? "x")
        } else if let fileName = self.name {
            return (parent?.virtualPath() ?? "x") + "/" + (fileName ?? "x")
        } else {
            return path
        }
    }
}

Perhaps the is a specific use case.

With the virtual path we can reorganise the file system structure based on the project structure such as:

extension PBXFileElement {
    func move() {
        if let group = self as? PBXGroup {
            if group.children.count <= 0 {
                // Just ignore empty group...
                return
            }
            group.children.forEach { $0.move() }
        } else {
            if let virtualPath = virtualPath(), let path = try? fullPath(sourceRoot: Path(""))?.url {
                // Move file from path -> `virtualPath`

Wonder if it's also possible to perform a nested hierarchy sort of groups & types? πŸ€”

Hola πŸ‘‹,

We want to inform you that the issue has been marked as stale. This means that there hasn't been any activity or updates on it for quite some time, and it's possible that it may no longer be relevant or actionable.
If you still believe that this issue is valid and requires attention, please provide an update or any additional information that can help us address it. Otherwise, we may consider closing it in the near future.
Thank you for your understanding.

Hola πŸ‘‹,

We want to inform you that we have decided to close this stale issue as there hasn't been any activity or response regarding it after marking it as stale.

We understand that circumstances may have changed or priorities may have shifted, and that's completely understandable. If you still believe that this issue needs to be addressed, please feel free to reopen it and provide any necessary updates or additional information.

We appreciate your understanding and look forward to your continued contributions to the project.

Thank you.