XCode 7.0.1.DMG Deployment

Journeay
New Contributor

Has anyone done the latest XCode release, XCode 7.0.1? I am trying to do, trying to deploy XCode 7.0.1 to developers as fast and efficiently as possible, and running into problems. Go figure.

So with BETA5 you could deploy the DMG and just have a post install script to handle the actual install, however the latest full version (7.0.1) is different. When you launch (mount) the downloadable DMG file it comes up with a GUI, that tells you to drag the XCode.app to Applications, which extracts XCode from the DMG to Applications.

Is there any scripting magic that can be preformed to accomplish this without having to extract the XCode.app (8gigs) from XCode.dmg (4gigs). That way I am not deploying 8gigs to hundreds of users?

Thanks,

Will

36 REPLIES 36

bpavlov
Honored Contributor

There's another way that's better. Download the installer from the MAS using this process:
https://derflounder.wordpress.com/2013/08/22/downloading-apples-server-app-installer-package/

Then have a script in the policy that runs AFTER:

#!/bin/sh

# DevToolsSecurity tool to change the authorization policies, such that a user who is a
# member of either the admin group or the _developer group does not need to enter an additional
# password to use the Apple-code-signed debugger or performance analysis tools.
/usr/sbin/DevToolsSecurity -enable

# Accept Xcode License
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept

# Install Additional Components
/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg -target /

/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target /

Journeay
New Contributor

Thank you for the info I will give this a shot.

Nix4Life
Valued Contributor

Quicknote: make sure your internal SUS is updated. It will save some time pulling down the command line tools

joecurrin
New Contributor III

@bpavlov we follow a similar process for installing additional components but it doesn't seem to run correctly with El Capitan. have you encountered this yet?

bpavlov
Honored Contributor

We haven't tried with El Capitan yet. When you say it doesn't run with El Capt, what errors are you getting?

joecurrin
New Contributor III

Basically, additional components do not install via postinstall script. You can run the command via terminal with no issues. But if you run it via a postinstall script, console throws back a ton of errors, and when you launch Xcode for the first time you are still prompted with installing additional components. Looks like SIP is wreaking havoc.

AVmcclint
Honored Contributor

After reading this post I figured I'd test deploying xcode 7.1.1 to my 10.11.2 tester Mac. I'm using the same .dmg and post-install script that I use on our Yosemite Machines. I watched as it copied the 9GB .app to /Applications and then it ran the script (very similar to @bpavlov's script) and then Self Service said it failed. I checked the log and it also says it failed, but I can't find any indication of actual failure.:

Script result: Dec 10 13:13:31 installer[3662] : Package Authoring Warning: The deleteObsoleteLanguages flag is ignored. No languages will be removed.
Dec 10 13:13:32 installer[3662] : Referenced component packages (1) trustLevel=501
Dec 10 13:13:32 installer[3662] : -[IFPKGDerivedDocument sortedPackageLocations]: result = (
"file://localhost"
)
Dec 10 13:13:32 installer[3662] : -[IFDInstallController(Private) _buildInstallPlanReturningError:]: location = file://localhost
Dec 10 13:13:32 installer[3662] : -[IFDInstallController(Private) _buildInstallPlanReturningError:]: file://localhost/Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg
Dec 10 13:13:32 installer[3662] : Set authorization level to root for session
Dec 10 13:13:32 installer[3662] : Administrator authorization granted.
Dec 10 13:13:32 installer[3662] : Will use PK session
Dec 10 13:13:32 installer[3662] : Using authorization level of root for IFPKInstallElement
Dec 10 13:13:32 installer[3662] : Starting installation:
Dec 10 13:13:32 installer[3662] : Configuring volume "Macintosh HD"
Dec 10 13:13:32 installer[3662] : Preparing disk for local booted install.
Dec 10 13:13:32 installer[3662] : Free space on "Macintosh HD": 212.67 GB (212672229376 bytes).
Dec 10 13:13:32 installer[3662] : Create temporary directory "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//Install.3662qbiAz1"
Dec 10 13:13:32 installer[3662] : IFPKInstallElement (1 packages)
Dec 10 13:13:32 installer[3662] : PackageKit: Enqueuing install with framework-specified quality of service (utility)
installer: Package name is MobileDevice
installer: Upgrading at base path /
installer: Preparing for installation….....
installer: Preparing the disk….....
installer: Preparing MobileDevice….....
installer: Waiting for other installations to complete….....
installer: Configuring the installation….....
installer: 
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
installer: Running package scripts….....
#
installer: Running package scripts….....
#
installer: Running package scripts….....
#
installer: Cleaning up….....
installer: Validating packages….....
#Dec 10 13:14:03 installer[3662] : Removing temporary directory "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//Install.3662qbiAz1"
Dec 10 13:14:03 installer[3662] : Finalize disk "Macintosh HD"
Dec 10 13:14:03 installer[3662] : Notifying system of updated components
Dec 10 13:14:03 installer[3662] : 
Dec 10 13:14:03 installer[3662] : **** Summary Information ****
Dec 10 13:14:03 installer[3662] : Operation Elapsed time
Dec 10 13:14:03 installer[3662] : -----------------------------
Dec 10 13:14:03 installer[3662] : zero 0.00 seconds
Dec 10 13:14:03 installer[3662] : disk 0.09 seconds
Dec 10 13:14:03 installer[3662] : install 31.18 seconds
Dec 10 13:14:03 installer[3662] : -total- 31.27 seconds
Dec 10 13:14:03 installer[3662] : 

installer: 
installer: Finishing the Installation….....
installer: 
#
installer: The software was successfully installed......
installer: The upgrade was successful.
Dec 10 13:14:03 installer[3723] : Package Authoring Warning: The deleteObsoleteLanguages flag is ignored. No languages will be removed.
Dec 10 13:14:03 installer[3723] : Referenced component packages (1) trustLevel=501
Dec 10 13:14:03 installer[3723] : -[IFPKGDerivedDocument sortedPackageLocations]: result = (
"file://localhost"
)
Dec 10 13:14:03 installer[3723] : -[IFDInstallController(Private) _buildInstallPlanReturningError:]: location = file://localhost
Dec 10 13:14:03 installer[3723] : -[IFDInstallController(Private) _buildInstallPlanReturningError:]: file://localhost/Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg
Dec 10 13:14:03 installer[3723] : Set authorization level to root for session
Dec 10 13:14:03 installer[3723] : Administrator authorization granted.
Dec 10 13:14:03 installer[3723] : Will use PK session
Dec 10 13:14:03 installer[3723] : Using authorization level of root for IFPKInstallElement
Dec 10 13:14:03 installer[3723] : Starting installation:
Dec 10 13:14:03 installer[3723] : Configuring volume "Macintosh HD"
Dec 10 13:14:03 installer[3723] : Preparing disk for local booted install.
Dec 10 13:14:03 installer[3723] : Free space on "Macintosh HD": 211.79 GB (211785162752 bytes).
Dec 10 13:14:03 installer[3723] : Create temporary directory "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//Install.3723LQqScE"
Dec 10 13:14:03 installer[3723] : IFPKInstallElement (1 packages)
Dec 10 13:14:03 installer[3723] : PackageKit: Enqueuing install with framework-specified quality of service (utility)
installer: Package name is MobileDeviceDevelopment
installer: Installing at base path /
installer: Preparing for installation….....
installer: Preparing the disk….....
installer: Preparing MobileDeviceDevelopment….....
installer: Waiting for other installations to complete….....
installer: Configuring the installation….....
installer: 
#
installer: Optimizing system for installed software….....
#
installer: Moving items into place….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
#
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
installer: Registering updated components….....
#
installer: Running package scripts….....
#
installer: Running package scripts….....
#
installer: Running package scripts….....
installer: Validating packages….....
installer: Validating packages….....
#Dec 10 13:14:31 installer[3723] : Removing temporary directory "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//Install.3723LQqScE"
Dec 10 13:14:31 installer[3723] : Finalize disk "Macintosh HD"
Dec 10 13:14:31 installer[3723] : Notifying system of updated components
Dec 10 13:14:31 installer[3723] : 
Dec 10 13:14:31 installer[3723] : **** Summary Information ****
Dec 10 13:14:31 installer[3723] : Operation Elapsed time
Dec 10 13:14:31 installer[3723] : -----------------------------
Dec 10 13:14:31 installer[3723] : zero 0.00 seconds
Dec 10 13:14:31 installer[3723] : disk 0.03 seconds
Dec 10 13:14:31 installer[3723] : install 28.11 seconds
Dec 10 13:14:31 installer[3723] : -total- 28.14 seconds
Dec 10 13:14:31 installer[3723] : 

installer: 
installer: Finishing the Installation….....
installer: 
#
installer: The software was successfully installed......
installer: The install was successful

I launched XCode and was quickly brought to the "Welcome to XCode splash screen" No prompts to install components appeared. All actual proof says the install was successful, but for some reason JSS 9.81 says it failed. Again, this is the exact same Policy that I install on Yosemite Macs and none of them show up in JSS as Failed. I'm getting real tired of "failures" that aren't actual failures.

AVmcclint
Honored Contributor

Here's the script I'm using

#!/bin/bash
# exclude xcode from gatekeeper verification, which can take hours.
if [[ -e "/Applications/Xcode.app" ]]; then xattr -dr com.apple.quarantine /Applications/Xcode.app
fi

# Accept EULA so there is no prompt

if [[ -e "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" ]]; then
  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
fi

# Install Mobile Device Package so there is no prompt

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

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

exit 0

rtrouton
Release Candidate Programs Tester

In the output, there's a section that says _buildInstallPlanReturningError. As it contains the word Error, Casper reports a failure.

To fix that, change the installer commands from /usr/sbin/installer -dumplog -verbose -pkg to /usr/sbin/installer -pkg. That should take the Error word out of the logs.

AVmcclint
Honored Contributor

UGH. The error recognition in JSS needs room for improvement.

I just looked at the logs from my Yosemite successes and they don't have that

_buildInstallPlanReturningError

part. I guess that's why they recorded as Completed.

Nix4Life
Valued Contributor

Hey Guys;

Also just started working on 10.11.2 test machine. I was able to get xcode 7.0 installed with a variation of that script using Munki with no problems going to step from 7.1 to 7.2 will update when done

LSinNY

joecurrin
New Contributor III

So what we do it slightly different than most. I repackage Xcode using the developer.apple.com version and add a postinstall script where the additional components install. This has worked flawlessly until 10.11. For whatever reason installing additional components via the postinstall results in failure, installing via a separate script results in success.

bpavlov
Honored Contributor

So I think I understand where some of you are running into problems. If you take an Apple-signed pkg that installs in SIP areas and try to call that via a postinstall script, the packages will fail to install successfully. This is because you are using an non-Apple signed package to essentially install in SIP areas which only Apple can do. Yes, you are ultimately calling an Apple pkg in the postinstall script, but that doesn't matter.

This was talked about a month or two ago on another thread where I made a similar discovery. Basically, what you want to do is call the Apple-signed pkg via a regular script (most likely an AFTER) and it should install successfully.

m_entholzner
Contributor III
Contributor III

@bpavlov Can you please specify what you mean with the "AFTER" script? how do you execute that within the Xcode install?

Nix4Life
Valued Contributor

a50fc837f1dc4fc2a33f93b610fb4789
Hey Guys;
I have installed Xcode on 10.11.1 (that was updated to 10.11.2 during imaging) from 7.0 to 7.2 with no issues using Munki with a postinstall script that behaves the way @bpavlov has suggested.

postinstall script -not sure where i got it, but I am not the original author:

#!/bin/sh
## postinstall

# Accept EULA so there is no prompt
if [[ -e "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" ]]; then
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept
fi
# Install Mobile Device Package so there is no prompt
if [[ -e "/Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg" ]]; then
/usr/sbin/installer -dumplog -verbose -pkg "/Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg" -target /
fi
if [[ -e "/Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg" ]]; then
/usr/sbin/installer -dumplog -verbose -pkg "/Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg" -target /
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"

    # Find the last listed update in the Software Update feed with "Command Line Tools" in the name

    cmd_line_tools=$(softwareupdate -l | awk '/* Command Line Tools/ { $1=$1;print }' | tail -1 | sed 's/^[[ 	]]*//;s/[[ 	]]*$//;s/*//' | cut -c 2-)

    #Install the command line tools

    softwareupdate -i "$cmd_line_tools" -v

    # Remove the temp file

    if [[ -f "$cmd_line_tools_temp_file" ]]; then
      rm "$cmd_line_tools_temp_file"
    fi
fi
sleep 5
sudo DevToolsSecurity -enable
/usr/sbin/dseditgroup -o edit -a everyone -t group _developer

exit 0      ## Success
exit 1      ## Failure

hth
Larry

bpavlov
Honored Contributor

@m.entholzner In your Casper policy add a script and make it an AFTER script so that it runs after installing Xcode. In my Casper policy, I have the Xcode pkg from the MAS, and the Xcode CLI Tools from the Dev site, and then an AFTER script which you've already seen posted in this thread.

donmontalvo
Esteemed Contributor III

Noticed 7.2 was released on Dec 8, assuming the above works with that version, downloaded from developer.apple.com. Nice scripts, especially liking the line to add all users to _developer group.

--
https://donmontalvo.com

m_entholzner
Contributor III
Contributor III

@bpavlov Thank you, that worked! I think it's time for christmas vacation... -.-

m_entholzner
Contributor III
Contributor III

It seems that Xcode 7.2.1 doesn't work anymore with this solution. Interesting is, when you install Xcode 7.2.1 on a clean machine and execute the postinstall, Xcode doesn't work. Installing Xcode 7.2 on the same machine (= downgrade), Xcode will start without any prompts.

It also seems that Xcode beta 7.3 works with the postinstall. Strange thing...

Anyone else seeing this behavior?

bpavlov
Honored Contributor

I pushed it out yesterday and it's working fine. When you say Xcode doesn't work anymore, what do you mean exactly?

m_entholzner
Contributor III
Contributor III

The deployment process isn't working for me. Xcode installs fine, the postinstall script is executed without issues. The packages seem to install fine, but Xcode prompts for that package installs after first launch. I've attached the script I'm using for postinstall. It is based on the script posted earlier in this thread.

#!/bin/bash

# XcodePostinstall.sh
# ----------------------------------------
# Version 1.2
# Created:  14.12.2015
# Modified: 18.01.2016

# Description
# This script will run some postinstall actions after Xcode installation. 

# Variables
SCRIPTNAME="XcodePostinstall.sh"
INFODIR="/Library/Management/"
INFOFILE="/Library/Management/informations.plist"
LOGFILE="/Library/Management/$(echo ${SCRIPTNAME} | cut -d . -f1).log"

if [ -d /Applications/Xcode.app ]
then
    XCODEVERSION=$(defaults read /Applications/Xcode.app/Contents/version.plist CFBundleShortVersionString)
    XCODEBUILD=$(defaults read /Applications/Xcode.app/Contents/version.plist ProductBuildVersion)
fi

if [ -d /Applications/Xcode-[bB]eta.app ]
then
    XCODEBETAVERSION=$(defaults read /Applications/Xcode-[bB]eta.app/Contents/version.plist CFBundleShortVersionString)
    XCODEBETABUILD=$(defaults read /Applications/Xcode-[bB]eta.app/Contents/version.plist ProductBuildVersion)
fi

# Functions

# ----------------------------------------
# Script

# Check if the Infodirectory exists
if [ ! -d ${INFODIR} ]
then
    mkdir -p ${INFODIR}
    chown -R root:admin ${INFODIR}
    chmod -R 755 ${INFODIR}
fi

printf "==================================================
" | tee -a ${LOGFILE}
printf "$(date "+%Y-%m-%d %H:%M:%S") ${SCRIPTNAME} running...
" | tee -a ${LOGFILE}

printf "Enabling DevTools Security...
" | tee -a ${LOGFILE}
DevToolsSecurity -enable 2>&1 | tee -a ${LOGFILE}

printf "Adding everyone to _developer group...
" | tee -a ${LOGFILE}
dseditgroup -o edit -a everyone -t group _developer 2>&1 | tee -a ${LOGFILE}

if [ -d /Applications/Xcode.app ]
then
    printf "Accepting GM license agreement...
" | tee -a ${LOGFILE}
    defaults write /Library/Preferences/com.apple.dt.Xcode.plist IDEXcodeVersionForAgreedToGMLicense -string ${XCODEVERSION} 2>&1 | tee -a ${LOGFILE}
    defaults write /Library/Preferences/com.apple.dt.Xcode.plist IDELastGMLicenseAgreedTo -string ${XCODEBUILD} 2>&1 | tee -a ${LOGFILE}

    printf "Installing GM Mobile Device development packages...
" | tee -a ${LOGFILE}
    installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg -target / 2>&1 | tee -a ${LOGFILE}
    installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target / 2>&1 | tee -a ${LOGFILE}
fi

if [ -d /Applications/Xcode-[bB]eta.app ]
then
    printf "Accepting Beta license agreement...
" | tee -a ${LOGFILE}
    defaults write /Library/Preferences/com.apple.dt.Xcode.plist IDEXcodeVersionForAgreedToBetaLicense -string ${XCODEBETAVERSION} 2>&1 | tee -a ${LOGFILE}  
    defaults write /Library/Preferences/com.apple.dt.Xcode.plist IDELastBetaLicenseAgreedTo -string ${XCODEBETABUILD} 2>&1 | tee -a ${LOGFILE}

    printf "Installing Beta Mobile Device development packages...
" | tee -a ${LOGFILE}
    installer -pkg /Applications/Xcode-[bB]eta.app/Contents/Resources/Packages/MobileDevice.pkg -target / 2>&1 | tee -a ${LOGFILE}
    installer -pkg /Applications/Xcode-[bB]eta.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target / 2>&1 | tee -a ${LOGFILE}
fi

printf "$(date "+%Y-%m-%d %H:%M:%S") ${SCRIPTNAME} finished.
" | tee -a ${LOGFILE}
printf "==================================================

" | tee -a ${LOGFILE}

exit 0

draeconis
New Contributor II

I'm having the same issue on my 10.10.5 VM, Xcode 7.2.1 still asks for additional components after running this script.

m_entholzner
Contributor III
Contributor III

Xcode 7.3 beta seems to work again... lets hope that this is a temporary issue.

AVmcclint
Honored Contributor

crap. I just encountered the additional components to install after putting xcode 7.2.1 on Self Service. Correct me if I'm wrong, but isn't xcode 7.3 only for OSX 10.11? We're still running 10.10 so I can't go to 7.3 if it has actually been fixed in that version. Can anyone figure out if there is an additional command we can add to the script to run so they are installed with the rest of the package instead of requiring admin rights to complete it?

The last bit of the install log in JSS indicates that the parts I DO have in the script installed fine, but there's obviously something else it needs.

Successfully installed Xcode 7.2.1.pkg.
[STEP 4 of 4]
Running script xcode_post_install.sh...
Script exit code: 0
Script result: installer: Package name is MobileDevice
installer: Upgrading at base path /
installer: The upgrade was successful.
installer: Package name is MobileDeviceDevelopment
installer: Upgrading at base path /
installer: The upgrade was successful.

AVmcclint
Honored Contributor

Maybe, possibly, perhaps I have a workaround. Even though the script successfully calls for /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg to install, I looked in /var/log/install.log and upon first launch of Xcode, this is the package it tries to install. Fine. I copied /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg out to my desktop and then uploaded to my JSS via Casper Admin and added it to the Xcode 7.2.1 policy to run after the main xcode install package. I still have the script set to run "After" the packages install. I deleted Xcode.app from my test Mac and re-ran the updated policy via Self Service. When it finished, I launched Xcode and this time it did not prompt to install additional components. I need to test again on a different Mac to confirm.

EDIT.... no such luck on a fresh install nor on an upgrade install. DRAT!

yakimant
New Contributor

Hi guys,

Thanks for post-install scripts.
Just wanted tom mention xcode-install, which can help somehow.

AVmcclint
Honored Contributor

As a result of the recent incident where a fake XCode was distributed to Chinese users and caused all kinds of mayhem, I don't think it would would be a good idea to download XCode from anywhere but directly from Apple.

djdavetrouble
Contributor III

took a look at xcode-install, you could script this
gem install fastlane
gem install xcode-install
fastlane-credentials add ?????
xcversion install 7.3.1
xcversion install-cli-tools

AVmcclint
Honored Contributor

FYI, I was able to confirm that Xcode 7.3.1 does install and the standard post-install scripts we've all been using does finally work, and xcode now no longer prompts to install additional components. Unfortunately it looks like 7.3.1 is only for running on OSX 10.11.x.

TomDay
Release Candidate Programs Tester

Silly question, probably an easy answer. Wondering why the script above didn't run to install the tools and realized xcode installed right to the HD rather that /Applications. Fill me in on why a DMG would install an app to the HD, not /Applications?

Also, anyone get the "Xcode 7 library documentation" to install with this?

Thanks!
PS, such a helpful post, in a time jam for a deployment and it looks like this is going to be perfect!

TomDay
Release Candidate Programs Tester

@bpavlov @AVmcclint Just wanted to say thanks for all the info here, works beautifully in conjunction with Rich Trouton's MAS process.

homepup
New Contributor III

Had a similar issue happen with Xcode 8.2.1 on macOS 10.12.3. Found that once I added this line to my scripts to also install:

/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/XcodeSystemResources.pkg -target /

It seemed MUCH happier.

stefmo
New Contributor

@homepup Which script did you add that line to?

homepup
New Contributor III

@stefmo Unfortunately, I'm not a JAMF user (still trying to convince the check-writers that it's worth it and will maybe allow my hair to grow back from less stress if we get it), but I cruise the forums for help and advice, so this was just a line added to my particular Xcode installation scripts for after imaging. Here's a copy of my current version (giving credit where it is due since 90% of this is borrowed from various sources/people/forums):

#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH

# Script to install Xcode components after initial installation (agree to license & mobile components installation)
echo "%95"

# exclude xcode from gatekeeper verification, which can take hours.
if [[ -e "/Applications/Xcode.app" ]]; then xattr -dr com.apple.quarantine /Applications/Xcode.app
fi

# Accept Xcode License
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -license accept

# Install Additional Components
/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg -target /

/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target /

/usr/sbin/installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/XcodeSystemResources.pkg -target /

# 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"

    # Find the last listed update in the Software Update feed with "Command Line Tools" in the name

    cmd_line_tools=$(softwareupdate -l | awk '/* Command Line Tools/ { $1=$1;print }' | tail -1 | sed 's/^[[ 	]]*//;s/[[ 	]]*$//;s/*//' | cut -c 2-)

    #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
sleep 5

# DevToolsSecurity tool to change the authorization policies, such that a user who is a
# member of either the admin group or the _developer group does not need to enter an additional
# password to use the Apple-code-signed debugger or performance analysis tools.
/usr/sbin/DevToolsSecurity -enable
/usr/sbin/dseditgroup -o edit -a everyone -t group _developer

echo "Xcode installations complete"

exit 0

AVmcclint
Honored Contributor

Has anyone tried the script on xcode 9 yet?

rwinfie
Contributor

As of xcode 9 you will need this line added to the script

installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/XcodeExtensionSupport.pkg -target /