Pre-Actions for Build in scheme have different running environment when run from Xcode vs xcodebuild

Number:rdar://FB8885049 Date Originated:6 November 2020, 1:15PM
Status:Open Resolved:
Product:Xcode Product Version:12.1
Classification:Incorrect/Unexpected Behavior Reproducible:Always
When trying to run a gradle task (any task, may be the generic "./gradlew tasks" task) in Xcode Pre-Actions for Build through Xcode - it works. When trying to run it though xcodebuild from the command line - the ./gradlew process hangs. 

This must mean that there is some difference in the running environment (some constraints on forking or permissions) between the GUI Xcode and CLI xcodebuild.

Please list the steps you took to reproduce the issue:

Open attached project in Xcode
Press play
Listen for "One" and "Two"

Open Terminal
xcodebuild -project GradlePreActionTest.xcodeproj -scheme GradlePreActionTest clean build
Run the above command
Listen for One and never get to Two as the project hangs

What did you expect to happen?
Both ways of running the Pre-Action script produce the same result

What actually happened?
Running the Pre-action through xcodebuild makes gradle hang


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!