Compute relative paths to support sources outside a spec's directory #524
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #318
Previously, XcodeGen would determine the relative path to a source by removing the project's
basePath
from the source's path, but this doesn't work when the source's path is outside the base path. For example, given a base path/a/b
and a path to a source../c
, XcodeGen would unsuccessfully try to remove "/a/b" from "/a/c" and wind up creating a "relative" file reference to "/a/c".This change adds a method to
Path
that computes the relative path between two paths, inspired by methods likePathname#relative_path_from
in Ruby, and uses it to determine the paths for top-level references in the project.I'm trying to decide whether I should really be contributing this to PathKit, since this solves a generalizable path problem, but since it fixes a specific bug in XcodeGen I wanted to put it up here. I'm happy to open a PR on PathKit in addition to this one, so that you don't get stuck maintaining a pathing algorithm 🙂