Posted on 11-16-2019 06:02 AM
Hi all- ever since xcode 11.x.x I have been having issues with multiple installs of xcode installed on a machine.
Sometime it works and my users have no admin prompt to install mobile pkg Other times they are faced with the admin promote to install the mobile pkg.
How can there be a consistent way to get MULTIPLE XCODE installs to work on 1 given machine without the requirement of admin rights.
I used rbouton scripts and they're have worked till recently... But now it's inconsistent
Please help and share any scripts you use to make this happen and use xcode 11.x with admin rights
Thanks
Solved! Go to Solution.
Posted on 11-16-2019 07:26 AM
/usr/sbin/dseditgroup -o edit -a everyone -t group _developer
/usr/sbin/DevToolsSecurity -enable
sudo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
exit 0
we also run that at login... The first script is ran everytime xcode updates and the second is ran at login for everyuser... We have been running xcode labs with network logins for 2 years without admin rights with no issues.
Posted on 11-16-2019 06:37 AM
Without admin rights*
Posted on 11-16-2019 07:23 AM
command_line_tools_dir="/Library/Developer/CommandLineTools"
xcode_cache="${HOME}/Library/Caches/com.apple.dt.Xcode"
if [[ -d "$command_line_tools_dir" ]]; then
sudo rm -rf "$command_line_tools_dir"
sudo rm -rf "$xcode_cache"
fi
osx_vers=$(sw_vers -productVersion | awk -F "." '{print $2}')
cmd_line_tools_temp_file="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
if [[ "$osx_vers" -ge 9 ]]; then
# Create the placeholder file which is checked by the softwareupdate tool # before allowing the installation of the Xcode command line tools.
touch "$cmd_line_tools_temp_file"
# Identify the correct update in the Software Update feed with "Command Line Tools" in the name for the OS version in question.
if [[ "$osx_vers" -gt 9 ]]; then cmd_line_tools=$(softwareupdate -l | awk '/* Command Line Tools/ { $1=$1;print }' | grep "$osx_vers" | sed 's/^[[ ]]//;s/[[ ]]$//;s///' | cut -c 2-) elif [[ "$osx_vers" -eq 9 ]]; then cmd_line_tools=$(softwareupdate -l | awk '/* Command Line Tools/ { $1=$1;print }' | grep "Mavericks" | sed 's/^[[ ]]//;s/[[ ]]$//;s///' | cut -c 2-) fi
# Check to see if the softwareupdate tool has returned more than one Xcode # command line tool installation option. If it has, use the last one listed # as that should be the latest Xcode command line tool installer.
if (( $(grep -c . <<<"$cmd_line_tools") > 1 )); then cmd_line_tools_output="$cmd_line_tools" cmd_line_tools=$(printf "$cmd_line_tools_output" | tail -1) fi
#Install the command line tools
softwareupdate -i "$cmd_line_tools" --verbose
# Remove the temp file
if [[ -f "$cmd_line_tools_temp_file" ]]; then
rm "$cmd_line_tools_temp_file"
fi
fi
if [[ "$osx_vers" -eq 7 ]] || [[ "$osx_vers" -eq 8 ]]; then
if [[ "$osx_vers" -eq 7 ]]; then DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg fi
if [[ "$osx_vers" -eq 8 ]]; then DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_osx_mountain_lion_april_2014.dmg fi
TOOLS=cltools.dmg
curl "$DMGURL" -o "$TOOLS"
TMPMOUNT=/usr/bin/mktemp -d /tmp/clitools.XXXX
hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse
# The "-allowUntrusted" flag has been added to the installer
# command to accomodate for now-expired certificates used
# to sign the downloaded command line tools.
installer -allowUntrusted -pkg "$(find $TMPMOUNT -name '*.mpkg')" -target /
hdiutil detach "$TMPMOUNT"
rm -rf "$TMPMOUNT"
rm "$TOOLS"
fi
/usr/sbin/dseditgroup -o edit -a everyone -t group _developer
/usr/sbin/DevToolsSecurity -enable
sudo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
sudo /usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg -target /
sudo /usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target /
sudo /usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/XcodeSystemResources.pkg -target /
sudo /usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/CoreTypes.pkg -target /
sudo xcodebuild -runFirstLaunch
exit 0
Posted on 11-16-2019 07:24 AM
That highlighted line is NEW for 11....
Posted on 11-16-2019 07:26 AM
/usr/sbin/dseditgroup -o edit -a everyone -t group _developer
/usr/sbin/DevToolsSecurity -enable
sudo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
exit 0
we also run that at login... The first script is ran everytime xcode updates and the second is ran at login for everyuser... We have been running xcode labs with network logins for 2 years without admin rights with no issues.
Posted on 11-17-2019 09:44 PM
Hi @alv2015591 you can make your script examples look better by clicking the >_ just above the text entry window in the JAMF forum. Basically it's using 3 backticks (key above tab on mac keyboard) to start and end the code block. You paste your code between the back ticks