Skip to content
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

Fix xcframework extraction when a project refers to a missing build directory #3135

Merged

Conversation

elliottwilliams
Copy link
Contributor

Projects with Cartfile dependencies typically contain a FRAMEWORKS_SEARCH_PATH entry like Carthage/Build/iOS. With --use-xcframeworks, that platform-specific folder ("iOS") might not exist. This makes the predicate in extractXCFrameworks fail, because resolvingSymlinksInPath() has realpath(3) semantics and will not resolve symlinks for a non-existant path.

Fixed by truncating the given URL down to its extant portion. Since we only care about matching the prefix, and since the Carthage/Build directory should always exist because symlinkBuildPathIfNeeded was called, this should be safe.

Fixes #3122. I tested using the Cartfile in this issue.

…irectory

Projects may search a directory like Carthage/Build/iOS, but under
--use-xcframeworks that platform-specific folder ("iOS") might not
exist. resolvingSymlinksInPath() follows realpath(3) semantics and will
not resolve symlinks in the components of a non-existant URL.

Fixed in extractXCFrameworks() by truncating the given URL down to its
extant portion. Since we only care about prefix matching, and since the
Carthage/Build URL will exists at build time due to
symlinkBuildPathIfNeeded, this is safe.

Fixes Carthage#3122 and testing using the Cartfile in the issue.
@tmspzz
Copy link
Member

tmspzz commented Mar 3, 2021

Are we sure this will end resolution to Carthage/Build/ and not chop backwards more than that?

@elliottwilliams
Copy link
Contributor Author

Are we sure this will end resolution to Carthage/Build/ and not chop backwards more than that?

@tmspzz I think so! When symlinkBuildPathIfNeeded is called at the start of the build process, it creates Carthage/Build/ if needed. So this is always being called when Carthage/Build exists.

(try? extantURL.checkResourceIsReachable()) == nil works because checkResourceIsReachable always throws an error when the file referenced does not exist. I can change the condition to (try? extantURL.checkResourceIsReachable()) != true though, which might make it clearer that we're iterating until the URL exists.

We ought to be able to write a unit test for this without too much effort. I'll see if I can do that soon.

@elliottwilliams
Copy link
Contributor Author

We ought to be able to write a unit test for this without too much effort. I'll see if I can do that soon.

Based on the way XcodeSpec is set up, I'm having trouble writing a test like this without being able to pass --use-xcframeworks (since this test needs to run on CI with older Xcode versions). Going to defer this until we have modernized our test suite :\

@elliottwilliams elliottwilliams merged commit 94c77f4 into Carthage:master Mar 4, 2021
@elliottwilliams elliottwilliams deleted the extract-when-partial-symlink branch March 4, 2021 22:58
@agirault
Copy link

agirault commented Mar 10, 2021

@elliottwilliams @tmspzz When can we expect a patch release that includes those changes? A lot of projects using Carthage can't build with 0.37 without this. Thank you!

Copy link

@Jeftttt Jeftttt left a comment

Choose a reason for hiding this comment

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

Js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build errors with nested dependencies and --use-xcframeworks
5 participants