Deploying Xcode in 2019

mpittcasd
Contributor

Is anyone deploying Xcode through the 'Mac App Store Apps' option with any success?

Our one app development class uses Xcode on the computers then tests on their iPads so I need to make sure the versions match for this to work. Previously I had been downloading Xcode and deploying manually but this is somewhat time consuming. Then if the iPad app updates that causes issues until I can get the computer app updated again.

When trying to install Xcode from the App Store through Self Service it fails, but I'm not able to find anything in the logs about why it fails. When trying to install it this way with Xcode already installed, the app itself opens but it doesn't seem to be updating to the latest version.

Anyone else having similar issues? I've deployed plenty of iPad apps this way without issue so I can't imagine it's that different.

2 ACCEPTED SOLUTIONS

tak10
Contributor II

If Xcode was manually installed on the computer previously, Mac App Store Apps install option will only open the Xcode application. You will need to remove the app (in this case Xcode) and re-install using VPP / Mac App Store Apps deployment. Once the VPP deployed Xcode is installed on the computer, it should automatically maintain to the latest version going forward as long as you specifically set it up to update automatically. 6a3ab3565aa245e9809f23ad0d159df4

I've had to follow this procedure for moving package based deployment to VPP / Mac App Store based deployment with multiple apps.

View solution in original post

chris_miller
Contributor

To build on what @tak10 said you can push out a terminal command to remove XCode and then it should be available to "reinstall" via self service. I've seen this with other apps just like he mentioned and this workflow seems to do the trick for us.

rm -rf /Applications/Xcode.app

View solution in original post

39 REPLIES 39

tak10
Contributor II

If Xcode was manually installed on the computer previously, Mac App Store Apps install option will only open the Xcode application. You will need to remove the app (in this case Xcode) and re-install using VPP / Mac App Store Apps deployment. Once the VPP deployed Xcode is installed on the computer, it should automatically maintain to the latest version going forward as long as you specifically set it up to update automatically. 6a3ab3565aa245e9809f23ad0d159df4

I've had to follow this procedure for moving package based deployment to VPP / Mac App Store based deployment with multiple apps.

chris_miller
Contributor

To build on what @tak10 said you can push out a terminal command to remove XCode and then it should be available to "reinstall" via self service. I've seen this with other apps just like he mentioned and this workflow seems to do the trick for us.

rm -rf /Applications/Xcode.app

mpittcasd
Contributor

Sorry for the late replies. Finally having some time to sit down and mess with this some more.

So for future record if anyone else is running into the same issue:

I logged into the VPP store and got licenses for Xcode. Then in JSS, I went into the "Mac App Store Apps" option to add Xcode. Under the VPP tab there is a checkbox for 'Assign VPP Content Assign VPP content to computers with macOS 10.11 or later" that I just saw the other day which allows free apps to be assigned to computers and not users. I believe this is the correct way to deploy free apps from the Mac App Store to the computers.

The issue I'm currently running into is when installing Xcode this way through Self Service it is taking a long time on every computer, but the license seems to be available correctly. I found out our caching server is full so we're working on that which will hopefully help once one download goes through correctly.

The other issue I'm having is impatient teachers, but I don't think you guys have an easy fix for those. I think I need to figure out how to lock down iPad app updates, maybe just for Xcode, so that they don't get the version out of sync until I can get Xcode managed and automatically updated on the Macs.

Fattic
New Contributor II

@tak10 Do you know if installing it with VPP also installs the command line tools?

mpittcasd
Contributor

That I don't, sorry. It's been a while since I implemented these, but rtrouton has an Xcode post install script or package you can use here: https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/xcode_post_install_actions I don't remember if this included the command line tools, but I've been using it since I first deployed Xcode and haven't heard of anything missing from my users.

mediacollege
New Contributor III

i tried building an Xcode 10.2.1 package with the script from rtrouton, but it seems the script doesnt run. xcode keeps asking to install additional content. when the script is run manually it installs without issues.. Do you guys expericence the same problems?

stephaniemm77
Contributor II

anyone solve this? looking to do the same thing

SCADtom
New Contributor III

I have been able to package all of the post install stuff and successfully deploy it, but, each user is still prompted to install the extras that are already there.

larry_barrett
Valued Contributor

If your Mac is setup with stock energy settings it will go to sleep before the initial installation can complete (on my network anyways). Xcode is like 8 GB or something. Change the setting for Turn Display Off to more than the stock 15 min (again, depends on how fast your network can deliver it). I failed 3x, changed the energy setting and it worked right away.

mpittcasd
Contributor

That's what I ended up doing. I was running out of time so I manually started my package from Self Service, but I did have to change the energy settings to prevent the computers from going to sleep while Xcode installs. I had to make an admin account for the class using Xcode for when it asks to install something during the initial launch and just in case something else would come up. Once Xcode updates I will report back if the managed app feature keeps it up to date automatically or not.

mhegge
Contributor III

I have never seen an app install SO SLOWLY. We are deploying via VPP.

It takes less time to install the entire Adobe CC 2019 suite via JAMF than it does to install XCode 11

mpittcasd
Contributor

Yeah mine are hit or miss with how long Xcode takes to install. I'm running into an issue now trying to get them all updated to 11.1. I used device-based VPP assignment but trying to use the Force Update option doesn't seem to be working for my computers. Anyone know if when using device-based assignment if I should have users set to All Users or Specific Users then leave it blank? I just read through the documentation and it doesn't say one way or the other.

admindaly
New Contributor III

I can echo how slow Xcode is to install. And it's like 13GB once installed. But it seems that as long as you wait long enough and maybe keep the machine awake like suggested above, it does seem to install.

I am also trying rtrouton's script but the updated version and still getting asked for admin login.
https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/install_xcode_command_line_tools

Is anyone having more luck?

GabeShack
Valued Contributor III

I'm seeing the same issue even when running our version of this script.
@rtrouton Any ideas about what might have changed?

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

FutureFacinLuke
Contributor II

My Process:

Command Line Tools for Xcode is installed as part of a package that requires it for log on auditing, the version installed is based on a per OS Smart Group and policy (10.13, 10.14, 10.15 etc...) using a common custom trigger.

Xcode installs from VPP via a Forced install for labs that require it or from Self Service for all other users.

Next I have a Smart Group: Populated by all Macs with Xcode installed (Criteria: App Has "Xcode')

Policy runs the following script on the Xcode group:

#!/bin/sh

# Post-install script for Xcode
# This script sets up and installs additional components for Xcode to prevent popups on first run for the user, then enables Developer Mode..."
# Re-written to remove DS environment variables so this will work as a standalone script
# 21-11-17
# Replaced installer commands with for loop to make this generic as xcode updates, confirmed as working on 10.3 06-07-19
# 01-04-19

echo "Starting Xcode post-install..."

# Accept Xcode License
echo "Accepting Xcode license..."
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
./xcodebuild -license accept
echo "...Xcode license accepted."

# Install Additional Components
echo "Installing Xcode additional components..."
cd /Applications/Xcode.app/Contents/Resources/Packages/
for PKG in $(find /Applications/Xcode.app/Contents/Resources/Packages -name "*.pkg"); do
  /usr/sbin/installer -dumplog -verbose -pkg "${PKG}" -target /
done

echo "...Xcode components installer finished."

# This part enables Developer Mode for programming with Xcode and elevates all user privileges

# Enable Developer Mode with devtools
echo "Enabling Developer Mode..."
cd /usr/sbin/
./DevToolsSecurity -enable
echo "...Developer Mode enabled."

# Make all users members of the builtin _developer group
echo "Elevating user privileges..."
cd /usr/sbin/
./dseditgroup -o edit -a everyone -t group _developer
echo "...User privileges set."

echo "...Xcode post-install done."

exit 0

I re-wrote it with the For Loop as the PKGs inside the App changed each year, this way it just does the lot without needing a re-write each version.

I forget where I pulled the script from and the Loop section from but it works in an agile way so it's version agnostic, yet to test extensively on Catalina...

tomhastings
Contributor II

As @mhegge stated, it does take a long time to install. I have it set to install at deployment (a.k.a., imaging). Adobe CC installs in 17m 10s, Xcode at 21m 26s. When I excluded anti-virus (which currently installs before Xcode), I got the install time down to 12m 1s.
Does anyone have any secrets to getting Xcode to install faster?

aghali
New Contributor III

@Initialised thank you for your code, it worked like a charm for me! I was using the code from rtrouton script and my students were still getting prompted to install additional components when they launched Xcode for the first time, which required them to enter an admin password to proceed. The only additional piece I do is that I download and push the latest Xcode Command Line Tools prior to running the script, I figured it might save some time but I believe your code does that as well.

kacey3
Contributor II

@Initialised - Thanks for this. It is the exact solution I needed today!

Have you determined if it should be run on a schedule to keep up with Xcode updated or does it seem to work once, always, and forever?

aghali
New Contributor III

@Initialised @kacey3 every time Xcode updates, I download the latest Command Line Tools and I deploy to the computers with the latest Xcode installed, then I run the script after the tools are installed.

kacey3
Contributor II

Hmmm. I've got Xcode deploying through the Mac App Store Apps management tool. I think for now I'll set the install script to run monthly and hopefully that will be often enough to keep everything up to date. I can always flush the policy if I discover that the computers need authorization again.

mpittcasd
Contributor

@kacey3 how well is your Xcode policy working? I am revisiting this issue once again with the 11.3.1 update for Xcode because only a handful of my computers are updating. I logged into three of them to test things again and they started to download the updated version automatically, but the teacher is reporting that when his students log in they don't get anything.

Is anyone else running Xcode on a laptop cart? I'm afraid that's probably my biggest problem at this point since they don't stay awake while in the cart, so I can't set a good time for the Mac App Store Apps thing to push out the update.

rmgmedia
New Contributor III

@Initialised
Were you able to test on Catalina? I am trying to make so Command Line Tools is deployed during enrollment.

seanism
New Contributor III

Yes the script to install Command Line Tools works on Catalina...
https://github.com/rtrouton/rtrouton_scripts/blob/master/rtrouton_scripts/install_xcode_command_line_tools/install_xcode_command_line_tools.sh

The name of commandline tools changed in Catalina so you need to have the updated version of the script. Make sure it has a check for MacOS version in it.

My own version of the commandline tools update is here: https://github.com/seanism/IT/blob/master/CommandLineTools.sh

beatlemike
Release Candidate Programs Tester

@kacey3 This script worked for you? Because every time I try to open Xcode I get stopped at the agreement still. I don't think anything changed since mid February ... it's Apple though so who knows

jrippy
Contributor III

I don't think you need to loop through the pkg installers anymore.

#!/bin/sh
/Applications/Xcode.app/Contents/Resources/usr/bin/xcodebuild -license accept
/Applications/Xcode.app/Contents/Resources/usr/bin/xcodebuild -runFirstLaunch  #This installs the Additional Components
/usr/sbin/DevToolsSecurity -enable
dseditgroup -o add everyone -t group _developer

That should be the barebones needed to get it working with everyone having developer privs. Of course, modify and sanity check as needed.

ssc
New Contributor II

I've just tested the following and it seems to be working. You can use modify the script so that it just has the lines that are required rather than the 'if' statement. You would just then need to scope it to a smart group that contains devices that have 'Xcode' installed. I just needed this to run ASAP and to know which computers didn't have Xcode.

#!/bin/bash

if [[ -d /Applications/Xcode.app ]]; then
  echo "Xcode installed"
  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -runFirstLaunch  #This installs the Additional Components
  /usr/sbin/DevToolsSecurity -enable
  dseditgroup -o add everyone -t group _developer
else
  echo "Xcode not installed"
  exit 1
fi

GabeShack
Valued Contributor III

@jrippy Note the above script (and I assume Xcode 12.1) changes the location of the xcodebuild process that used to be in /Applications/Xcode.app/Contents/Resources/xcodebuild
To
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild

Thats what was failing for me previously.

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

jrippy
Contributor III

@gshackney Thanks!

jrippy
Contributor III

@ssc There's plenty more checking that could be done. For example, you could also use a smart group to determine which computers have Xcode installed and only scope to those.
However you want to implement it though, I was trying to provide just the needed commands to get it working.
I did have the wrong path for newer versions so I'm glad @gshackney pointed that out.

GabeShack
Valued Contributor III

The only thing I can't remember if we need to install command line tools or is it bundled in the extra installs in the above scripting?

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

tomt
Valued Contributor

I always install them as a separate package, just to be sure. However, there is no release version of the 12.1 CLTs (just the GM version).

GabeShack
Valued Contributor III

@tomt yea I noticed the gm version and am considering just installing it instead of waiting. Also wondering if once the command line tools are installed can non admin users run the update for them when prompted?

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

tomt
Valued Contributor

@gshackney Can't answer that one, I'll just push the updated CLT package if they release a full 12.1 or add the updated one to my 12.2 policy once it gets finished.

zseigh
New Contributor II

@Initialised Your script solved my problem with Xcode 12.1 asking for additional components after install even after I though I had scripted the install for everything. Thanks so much!

UESCDurandal
Contributor II

So, when everyone says that Managed Distribution (VPP) Xcode installation via Self Service is slow... are you talking like upwards of an hour before it appears in the applications folder? And if you click on anywhere else within Self Service while that process is running then the "Installing..." status will revert back to the Install button?

Because that's our current experience when trying to manage Xcode via Jamf Pro. It's so bad that we're instructing our users to leverage consumer Apple IDs to install Xcode from the App Store themselves. Which is all the more frustrating for our employees since we've federated our domain with ABM for Managed Apple IDs and they're discovering that they can not use them to install free apps.

Installing Xcode the normal way via the App Store takes a reasonable amount of time considering the file size. Attempting to install via Jamf Self Service is a horrible user experience IMO.

beatlemike
Release Candidate Programs Tester

@UESCDurandal both are god awful slow... omg I love your handle... but I digress. Yeah because both are so slo and yess VPP in Self Service is ridiculously so, I've taken to installing it as a package which is much faster. Of course that leaves you to manage the updates as well, but frankly I rather it just work and be efficiently installed.

anudeepreddy
New Contributor II

Did Xcode installation break MacOS software updates for anyone else?

gyoshi2002
New Contributor

I'm hoping ppl are still following this thread. Xcode 12.4 downloaded from developer site is 11.66 GB. I've zipped it, and uploaded to our cloud instance. Pulling that down during provisioning our eng build actually isn't that bad. However, once it's downloaded, and then beings to extract using: xip --expand Xcode_12.4.xip

It takes anywhere from 40 mins to 2 hrs, on both physical hardware and VMs. Has anyone figured out a quicker way to deploy this application? Is there another extraction tool? Is there any sense in attempting a snapshot packaged install, or packing the 30 GB install? The License agreements, and installing CLI only add another 15 mins.

gabester
Contributor III

@user-iYzHNAwDQp Hey yes we're doing almost exactly the same thing here, the difference being on premise instead of cloud. In Self Service we warn users, per @alexmcclements "This fully installs Xcode - a 12GB package, this will take a VERY loonnnnnnnggggg time, you've been warned! Requires 30GB free disk space to start."

In theory you could deploy it as a DMG, then with a script mount the DMG, and make an alias in /Applications to Xcode.app on the DMG... But I've not got the cycles to tinker with it. I've long wanted to do something similar with MS Office, at least up until the very most recent couple of versions took forever to install, first unpacking from the PKG to /tmp then using ditto to copy to /Applications, esp since each Office app is replicating 500MB of fonts? Isn't APFS supposed to have some magic to make installs like this better?