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

[Project] Legacy Build Location Support #2880

Conversation

samdmarshall
Copy link
Contributor

Submitting fix to modify the Pods.xcodeproj PBXProject default build path ("SYMROOT") so that when dependencies get built to the correct locations in a standard configuration.

Background:
By default Xcode configures itself to be set to creating unique build directories in the ~/Library/Developer/Xcode/DerivedData/ based on the project/workspace file. This setting can be changed by opening Xcode's Preferences > Locations, then clicking the button "Advanced..." listed under the "Derived Data" setting. Here one can set the default build location behavior for Xcode to use. When selecting "Legacy" this will have each project's targets get built to "SYMROOT", relative to the "SRCROOT" or "PROJECT_DIR" for that project.

Due to the default configuration for cocoapods, the Pods.xcodeproj file is stored in a subdirectory "Pods" that is (typically) listed along-side the user's Xcode project file and the newly created xcworkspace file. As a result, this means that all of the targets in Pods.xcodeproj will be built to a separate build folder and the aggregate target will have linker errors because it cannot find the library targets from Pods.xcodeproj.

Fix:
To resolve this in the common case, setting the build path ("SYMROOT") of the Pods.xcodeproj to be set to "SRCROOT/../build" which will correctly deposit the built products from Pods.xcodeproj into the same build directory as the user's xcodeproj targets.

Notes:
This setting doesn't impact any usage outside of the Legacy or Custom Project based build settings, where the build directory of the user's xcodeproj wouldn't be the same directory as the one used by Pods.xcodeproj.

This could use additional work, specifically the "SYMROOT" of the Pods.xcodeproj file should be set instead to "SRCROOT/RELATIVE_PATH_TO_USERS_XCODEPROJ_DIR/SYMROOT_FROM_USERS_XCODEPROJ". However resolving these paths correctly is far outside of my skill right now.

Existing users that use Custom or Legacy build locations in the common case (where the podfile is stored in the same directory as the user's xcodeproj file) will see an extra step removed. Users that store the podfile in a location that is not along-side their xcodeproj file will still have to manually adjust the build location paths as they have had to do so far.

@segiddins
Copy link
Member

All of the failures seem to be expected integration spec changes 👍

@alloy
Copy link
Member

alloy commented Nov 26, 2014

@samdmarshall Thanks! Can you please add a CHANGELOG entry that describes it as succinctly as possible. Preferably a bit shorter than this blog post? ;)

However, before merging, I would like to see a test for the change and also the change with regards to locating a user’s Xcode project. I can do this or someone else can pick this up if I don’t get to it before then.

@samdmarshall samdmarshall force-pushed the xclegacy-build-setting-build-dir-fix branch from d3581c1 to 8a94be7 Compare November 26, 2014 18:48
…odeproj get resolved correctly from user's xcodeproj targets, updating changelog
@samdmarshall
Copy link
Contributor Author

As i basically know absolutely no ruby at all you probably don't want me writing a test for this :)

@@ -21,6 +21,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#2639](https://github.com/CocoaPods/CocoaPods/issues/2639)

* Adding Xcode Legacy build location support for default Pods.xcodeproj
Copy link
Member

Choose a reason for hiding this comment

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

period + 2 spaces, please :)

@alloy
Copy link
Member

alloy commented Nov 26, 2014

This could use additional work, specifically the "SYMROOT" of the Pods.xcodeproj file should be set instead to "SRCROOT/RELATIVE_PATH_TO_USERS_XCODEPROJ_DIR/SYMROOT_FROM_USERS_XCODEPROJ".

@samdmarshall After thinking this over for a bit, I’m wondering about this part. Does this still work in the context of a workspace, or does one not use a workspace when using legacy build settings such as this?

The reason I’m asking is because in a workspace CocoaPods can support multiple user Xcode projects and I’m not sure what the SYMROOT would then be. Would it be a common dir?

@samdmarshall
Copy link
Contributor Author

That is where this gets tricky and up to the end user to a degree. What would happen then is that end user would have to decide on a common build directory or add in custom search paths themselves for the linkage to work correctly. At that point i'd deem it Someone Else's Problem™ -- meaning that the developer has to configure that themselves irrespective of this patch being in place.

@alloy
Copy link
Member

alloy commented Nov 27, 2014

Ok. In this case I think that we then should not try to automatically determine the path, as we cannot provide a full solution. Instead, what we can do is have a shortcut method which can be used to easily set the SYMROOT on all configurations from a user’s Podfile’s post_install hook and default it to the hardcoded version that you used in your current patch.

@samdmarshall
Copy link
Contributor Author

There needs to be a "default" solution in place based on a common case -- the Podfile being in the same directory as the user's xcodeproj. Keeping the existing SYMROOT default directory in the Pods.xcodeproj continues to ignore the problem and puts the burden onto the end user to specify a SYMROOT path that works for them. Setting a default for the known common case (mentioned) does no harm to anyone using non-Legacy settings and can only benefit everyone else. I see no reason to not have a way to configure this in the post_install hook, however this is not the place for this specific patch as it does nothing but shifts the burden of configuration further into the user's domain.

I am sorry to be such a stick-in-the-mud about this issue but this is one of the main pains i have with using cocoapods at all, since it literally will not work out of the box based on my Xcode settings. Settings which are still supported in the latest builds of Xcode. I don't think it is unreasonable to ask for this to exist as the default behavior as it mitigates an extra configuration step for some people and doesn't impact the majority of users in the first place.

@samdmarshall
Copy link
Contributor Author

This hasn't been touched in almost 3 weeks, if we are just waiting on the integration tests i can try to write them myself with some guidance.

@kylef kylef added this to the 0.36.0 milestone Dec 23, 2014
@kylef
Copy link
Contributor

kylef commented Jan 16, 2015

@alloy ping on this one

@kylef kylef added the s1:awaiting input Waiting for input from the original author label Jan 31, 2015
@kylef kylef removed this from the 0.36.0 milestone Feb 3, 2015
@alloy
Copy link
Member

alloy commented Feb 24, 2015

Closed in favour of #3183.

@alloy alloy closed this Feb 24, 2015
@ZepedaHector
Copy link

Submitting fix to modify the Pods.xcodeproj PBXProject default build path ("SYMROOT") so that when dependencies get built to the correct locations in a standard configuration.

Background: By default Xcode configures itself to be set to creating unique build directories in the ~/Library/Developer/Xcode/DerivedData/ based on the project/workspace file. This setting can be changed by opening Xcode's Preferences > Locations, then clicking the button "Advanced..." listed under the "Derived Data" setting. Here one can set the default build location behavior for Xcode to use. When selecting "Legacy" this will have each project's targets get built to "SYMROOT", relative to the "SRCROOT" or "PROJECT_DIR" for that project.

Due to the default configuration for cocoapods, the Pods.xcodeproj file is stored in a subdirectory "Pods" that is (typically) listed along-side the user's Xcode project file and the newly created xcworkspace file. As a result, this means that all of the targets in Pods.xcodeproj will be built to a separate build folder and the aggregate target will have linker errors because it cannot find the library targets from Pods.xcodeproj.

Fix: To resolve this in the common case, setting the build path ("SYMROOT") of the Pods.xcodeproj to be set to "SRCROOT/../build" which will correctly deposit the built products from Pods.xcodeproj into the same build directory as the user's xcodeproj targets.

Notes: This setting doesn't impact any usage outside of the Legacy or Custom Project based build settings, where the build directory of the user's xcodeproj wouldn't be the same directory as the one used by Pods.xcodeproj.

This could use additional work, specifically the "SYMROOT" of the Pods.xcodeproj file should be set instead to "SRCROOT/RELATIVE_PATH_TO_USERS_XCODEPROJ_DIR/SYMROOT_FROM_USERS_XCODEPROJ". However resolving these paths correctly is far outside of my skill right now.

Existing users that use Custom or Legacy build locations in the common case (where the podfile is stored in the same directory as the user's xcodeproj file) will see an extra step removed. Users that store the podfile in a location that is not along-side their xcodeproj file will still have to manually adjust the build location paths as they have had to do so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s1:awaiting input Waiting for input from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants