Skip to main content
Question

XCode - how to automate the "install additional component" at first start


Forum|alt.badge.img+10

Hi all,

I've search for this topic a bit, but can't find an answer. So I'm typing up a new question.

I install the latest XCode onto the Mac. During first start up, it will have this screen
I would then click on install, and type in my admin password to perform the installation.

Now I want to automate this step, as I want to do this on multiple build agents that will regularly get the latest XCode available. Is there any command or script that will trigger this off?

11 replies

Forum|alt.badge.img+16
  • Honored Contributor
  • 330 replies
  • September 12, 2018

It used to be that you could script the contents of /Applications/Xcode.app/Contents/Resources/Packages to install as part of the initial install, but that doesn't seem to do it any longer. I haven't found a solve for this yet.


Forum|alt.badge.img+7
  • Contributor
  • 55 replies
  • September 12, 2018

https://www.jamf.com/jamf-nation/discussions/21248/deploying-xcode-8-via-self-service-a-how-to


rickgmac
Forum|alt.badge.img+9
  • Valued Contributor
  • 62 replies
  • September 12, 2018

Try this

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/xcode_post_install_actions


AVmcclint
Forum|alt.badge.img+21
  • Esteemed Contributor
  • 1043 replies
  • September 12, 2018

I can confirm that the script on rtouton's github page does work with xcode 9.4.1.


Forum|alt.badge.img+7

I'm getting that as well, I've tried Rich's script and a number of others without success.


Forum|alt.badge.img+7

I added this line to Rich's code and it now works, there is an additional package which now needs installed which isn't in the original script.

Install XcodeExtensionSupport.pkg so there is no prompt

if [[ -e "/Applications/Xcode.app/Contents/Resources/Packages/XcodeExtensionSupport.pkg" ]]; then
/usr/sbin/installer -dumplog -verbose -pkg "/Applications/Xcode.app/Contents/Resources/Packages/XcodeExtensionSupport.pkg" -target /
fi


Stevie
Forum|alt.badge.img+7
  • Contributor
  • 35 replies
  • September 18, 2018

We deploy our Xcode with the version number appended to the filename so that our developers can pick which version they want to used. We deploy the application then run the following three lines which work well.

sudo xcode-select -s /Applications/Xcode 10.0.app/Contents/Developer
sudo /usr/bin/xcodebuild -runFirstLaunch'
sudo /usr/bin/xcodebuild -license accept


Forum|alt.badge.img+8
  • Valued Contributor
  • 126 replies
  • September 19, 2018

try this:
(based on @rtrouton work)

#!/bin/sh 

if [ -e /Applications/Xcode.app ]
then

sudo xcodebuild -license accept
# 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 
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept 
# install embedded packages 
# 
cd /Applications/Xcode.app/Contents/Resources/Packages/
sudo installer -pkg MobileDevice.pkg -target /
sudo installer -pkg MobileDeviceDevelopment.pkg -target /
# sudo installer -pkg XcodeExtensionSupport.pkg -target / ## no longer required
sudo installer -pkg XcodeSystemResources.pkg -target /

exit 0
else
echo "waiting for app trying again at next checkin"
exit 0
fi

Forum|alt.badge.img+8
  • Valued Contributor
  • 126 replies
  • September 19, 2018

and yes you don't need the sudo.....


Forum|alt.badge.img+11
  • Valued Contributor
  • 183 replies
  • September 19, 2018

this is worth looking at, very recent and carl's work is solid: https://github.com/carlashley/xcode_tools


Forum|alt.badge.img+8
  • Valued Contributor
  • 126 replies
  • November 17, 2020

So, it looks like Apple has made this much easier now - don't know when they did it, but running the command:

sudo /usr/bin/xcodebuild -runFirstLaunch

Will accept the license and install all additional components.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings