Skip to content

[Feature][DerivedData] Add an environment variable to customize the derived data path #12331

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PatShen
Copy link

@PatShen PatShen commented Apr 2, 2024

I made this PR to add an environment variable COCOAPODS_DERIVED_DATA_PATH to customize the -derivedDataPath of xcodebuild when user attempts to run the CocoaPods command, such as pod lib lint, pod repo push, etc.

@PatShen
Copy link
Author

PatShen commented Apr 3, 2024

When I set the environment variable like COCOAPODS_DERIVED_DATA_PATH=~/Desktop/DerivedData, the script will run with a -derivedDataPath parameter

Screenshot 2024-04-03 at 09 23 51

@stidch
Copy link

stidch commented Dec 17, 2024

I like this idea and we're missing this feature. There is no other way to force using another DerivedData folder, is there?

@PatShen
Copy link
Author

PatShen commented Feb 13, 2025

I like this idea and we're missing this feature. There is no other way to force using another DerivedData folder, is there?

Thank you for loving this idea. And yes, at present.

@stidch
Copy link

stidch commented Feb 13, 2025

We're currently using this approach:

  1. Add a custom xcodebuild file, like

    if [ -n "$XCODE_DERIVED_DATA_PATH" ]; then
        /usr/bin/xcodebuild -derivedDataPath "$XCODE_DERIVED_DATA_PATH" "$@"
    else
         /usr/bin/xcodebuild "$@"
    fi
    

    the path of xcodebuild can be different in your case.

  2. Make sure the script is executable:

    chmod +x /path/to/folder/of/the/xcodebuild_wrapper/xcodebuild
    
  3. Make sure the folder of this script is listed in your $PATH before /usr/bin.

    export PATH=/path/to/folder/of/the/xcodebuild_wrapper:$PATH
    
  4. Set the environment variable XCODE_DERIVED_DATA_PATH to your desired path.

    export XCODE_DERIVED_DATA_PATH=/path/to/desired/derivedData
    
  5. Use xcodebuild as you normally would. The wrapper will automatically add the -derivedDataPath parameter if the variable is set.

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