Xcode 11.x.x asking for admin - no matter which scripts I use

Caspernewbie202
New Contributor II

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

1 ACCEPTED SOLUTION

alv2015591
New Contributor III

!/bin/sh

make sure all users on this machine are members of the _developer group

/usr/sbin/dseditgroup -o edit -a everyone -t group _developer

enable developer mode

/usr/sbin/DevToolsSecurity -enable

accept Xcode license

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.

View solution in original post

5 REPLIES 5

Caspernewbie202
New Contributor II

Without admin rights*

alv2015591
New Contributor III

!/bin/bash

#########################################################################################

Xcode Command Line Tools Install

#########################################################################################

Check for current xcode command line tools and xcode cache and remove if found

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

Installing the Xcode command line tools on 10.7.x or higher

osx_vers=$(sw_vers -productVersion | awk -F "." '{print $2}')
cmd_line_tools_temp_file="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"

Installing the latest Xcode command line tools on 10.9.x or higher

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

Installing the latest Xcode command line tools on 10.7.x and 10.8.x

on 10.7/10.8, instead of using the software update feed, the command line tools are downloaded

instead from public download URLs, which can be found in the dvtdownloadableindex:

https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex

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

#########################################################################################

UI NonAdmin

#########################################################################################

make sure all users on this machine are members of the _developer group

/usr/sbin/dseditgroup -o edit -a everyone -t group _developer

enable developer mode

/usr/sbin/DevToolsSecurity -enable

accept Xcode license

sudo /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept

install embedded packages

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

alv2015591
New Contributor III

That highlighted line is NEW for 11....

alv2015591
New Contributor III

!/bin/sh

make sure all users on this machine are members of the _developer group

/usr/sbin/dseditgroup -o edit -a everyone -t group _developer

enable developer mode

/usr/sbin/DevToolsSecurity -enable

accept Xcode license

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.

View solution in original post

dlondon
Valued Contributor

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