I use several shell scripts that call xcodebuild to build.
I am running my 1st shell script using sudo which then fires off 3 or 4 other shell scripts to build my product. For each project I have a block of code that looks like this:
cd "${LOCAL_COMPONENTS_BUILD_PATH}/Daemon"
xcodebuild -project "Daemon.xcodeproj" -alltargets -configuration "Deployment"
cd "${LOCAL_COMPONENTS_BUILD_PATH}/Daemon/build/Deployment"
${DITTO} "${DAEMON_NAME}" "${DAEMON_OUTPUT_PATH}"
cd "${DAEMON_OUTPUT_PATH}"
chgrp "${SUDO_USER}" "${DAEMON_NAME}"
chown "${SUDO_USER}" "${DAEMON_NAME}"
I am logged in as the "admin" account on my system when I run my script with sudo so and I can see the "build" dirs after my scripts run. The build dirs don't have the red lock icon on them, just their x bits cleared for group and others (but not for owner) in the filesystem.
Any subsequent attempts to build the affected projects either from a script or manually in XCode fails with Xcode saying permission denied.
I solved the problem for now by cleaning all the projects after build and then removing the build dirs like this:
cd "${LOCAL_COMPONENTS_BUILD_PATH}/Daemon/"
xcodebuild -project "Daemon.xcodeproj" -alltargets -configuration "Deployment" clean
rm -R -f "build"
but it would be nice to know why that is happening.