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 build issues by removing nested PINOperation.xcodeproj #282

Conversation

elliottwilliams
Copy link
Contributor

@elliottwilliams elliottwilliams commented Sep 9, 2020

Hello! Here's a quick fix for Carthage users:

This change replaces the PINOperation.xcodeproj nested inside PINCache.xcodeproj with a workspace containing both projects. It doesn't impact building of PINCache itself, and it fixes a duplicate target error users will get if they try to build both projects within Xcode.

Background

Currently, PINCache checks Carthage/Checkouts/PINOperation into git, but it also lists PINOperation in its Cartfile. As a result, Carthage users who depend on PINCache will get two distinct copies of PINOperation checked out:

Carthage/Checkouts/PINOperation                             
Carthage/Checkouts/PINCache/Carthage/Checkouts/PINOperation

PINCache.xcodeproj embeds the second PINOperation and has target dependencies on it. This causes a couple issues:

  1. If you build using carthage build, PINOperation compiles twice: once when building PINOperation (the carthage dependency), and once when building PINCache.

  2. If you add PINOperation and PINCache's xcodeprojs to a workspace and try to build from there, you get a build error because Xcode has loaded both PINOperation projects, and therefore sees duplicate targets:

     error: Multiple commands produce 'Build/Products/Debug-iphonesimulator/PINOperation.framework/PINOperation':
     1) Target 'PINOperation' has link command with output 'Build/Products/Debug-iphonesimulator/PINOperation.framework/PINOperation'
     2) Target 'PINOperation' has link command with output 'Build/Products/Debug-iphonesimulator/PINOperation.framework/PINOperation'
    

Alternatives

Instead of creating an xcworkspace, I think this could also be fixed by:

  • Removing Carthage/Checkouts/PINOperation from git, so that on a user's machine the directory will be a symlink back to whatever version of PINOperation Carthage checked out.
  • Removing PINOperation from the Cartfile altogether and adding PINOperation's scheme to PINCache's project, so that PINCache indicates to Carthage that it produces both frameworks.

Testing done

  • make carthage still resolves and builds successfully
  • Created a Carthage project listing this version of PINCache, and carthage bootstrap built successfully.

@elliottwilliams
Copy link
Contributor Author

So…turns out the first approach (using Cartfile.private) doesn't actually work when integrating PINCache in another project 😛

Updated to move the embedded PINOperation.xcodeproj to a workspace, and confirmed that this fixes the build errors I was seeing downstream.

@garrettmoon garrettmoon self-assigned this Oct 1, 2020
@garrettmoon
Copy link
Collaborator

Thanks for putting this up! I think the Makefile analyze command needs to be updated? Possibly others?

@garrettmoon
Copy link
Collaborator

Hmm, looks like this is still failing even after updating the Makefile. I think we'll have to figure out why it's failing before this can be merged.

PINCache does not _embed_ PINOperation, only links it such that the
binary declares it needs PINOperation to run. This permits Xcode to
recognize the dependency relationship in the workspace.
@elliottwilliams elliottwilliams changed the title Fix build issues by moving PINOperation to Cartfile.private Fix build issues by removing nested PINOperation.xcodeproj Oct 7, 2020
@elliottwilliams
Copy link
Contributor Author

@garrettmoon thanks & good catch! I guess what I didn't realize was that PINCache didn't link against PINOperation (so Xcode didn't see an implicit dependency relationship between them). I've gone ahead and made PINCache link (but not embed) PINOperation. The Make commands are succeeding for me now, and I've verified in a downstream project that PINCache still builds :)

Worth noting here that linking here does change the PINCache binary by indicating that it depends on PINOperation.framework. But this change shouldn't be meaningful, since PINCache will always fail to load at runtime if PINOperation is missing.

Copy link
Collaborator

@garrettmoon garrettmoon left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@garrettmoon garrettmoon merged commit 222a996 into pinterest:master Oct 13, 2020
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.

2 participants