Xcode 9.2 Deployment

mpittcasd
Contributor

Is anyone deploying the newest Xcode? I'm not sure how to go about it now on High Sierra. Before I would get the install package from the App Store using the method by @rtrouton but it looks like there's no more Debug menu to get to the downloads folder. I am not sure how else to get the package for Xcode 9.

I did try using the Mac App Store Apps option in the JSS but it opens the App Store to the Xcode page after running this policy in Self Service. In the past I had tried capturing the installation with Composer but if I recall correctly it would either have issues installing or running using this method.

6 REPLIES 6

stutz
Contributor

Use this AppStoreExtract tool:

https://github.com/maxschlapfer/MacAdminHelpers/tree/master/AppStoreExtract

I use this whenever I need to deploy software from the Mac App Store. BTW it doesn't require the debug menu.

mpittcasd
Contributor

Thanks for that. I'm running into an issue when I try to run the script that it says permission denied. This happens on both admin accounts I tried as well as a regular user account. I tried following Rich's guide here but I don't see any mention of permission denied happening anywhere. Is there a different security option I might need to change? I've only ever had issues with allowing from sources other than the App Store.

bvrooman
Valued Contributor

Xcode can also be downloaded here: https://developer.apple.com/download/more/

RobertHammen
Valued Contributor II

@AdamBritt Here's an AppleScript that can get your App Store temporary folder.

set p2t to path to temporary items from local domain
tell application "System Events"
    set p2appStore to (path of container of container of p2t) & "C:com.apple.appstore:"
end tell
tell application "Finder" to open p2appStore

RobertHammen
Valued Contributor II

Here's the postinstall script that I'm using after deploying that package. It's a conglomeration of things from @rtrouton and Nick Cobb, with the last line from @donmontalvo's post here on Jamf Nation.

#!/bin/bash

# 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

# Just in case the xcodebuild command above fails to accept the EULA, set the license acceptance info 
# in /Library/Preferences/com.apple.dt.Xcode.plist. For more details on this, see Tim Sutton's post: 
# http://macops.ca/deploying-xcode-the-trick-with-accepting-license-agreements/

if [[ -e "/Applications/Xcode.app/Contents/Resources/LicenseInfo.plist" ]]; then

   xcode_version_number=`/usr/bin/defaults read "/Applications/Xcode.app/Contents/"Info CFBundleShortVersionString`
   xcode_build_number=`/usr/bin/defaults read "/Applications/Xcode.app/Contents/Resources/"LicenseInfo licenseID`
   xcode_license_type=`/usr/bin/defaults read "/Applications/Xcode.app/Contents/Resources/"LicenseInfo licenseType`

   if [[ "${xcode_license_type}" == "GM" ]]; then
       /usr/bin/defaults write "/Library/Preferences/"com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense "$xcode_version_number"
       /usr/bin/defaults write "/Library/Preferences/"com.apple.dt.Xcode IDELastGMLicenseAgreedTo "$xcode_build_number"
    else
       /usr/bin/defaults write "/Library/Preferences/"com.apple.dt.Xcode IDEXcodeVersionForAgreedToBetaLicense "$xcode_version_number"
       /usr/bin/defaults write "/Library/Preferences/"com.apple.dt.Xcode IDELastBetaLicenseAgreedTo "$xcode_build_number"
   fi       

fi

# 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

# Add all users to developer group, if they're not admins

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

# If you have multiple versions of Xcode installed, specify which one you want to be current.

/usr/bin/xcode-select --switch /Applications/Xcode.app

# Bypass Gatekeeper verification for Xcode, which can take hours.

if [[ -e "/Applications/Xcode.app" ]]; then xattr -dr com.apple.quarantine /Applications/Xcode.app
fi

# Install Mobile Device Packages so there are no prompts

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

# Install XcodeExtensionSupport.pkg

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

# Install XcodeSystemResources.pkg

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




# Install Command Line Tools.

if [[ /usr/bin/xcode-select ]]; then
    /usr/bin/xcode-select --install
fi

# Allow any member of _developer to install Apple-provided software.
# be sure you really want to do this.

/usr/bin/security authorizationdb write system.install.apple-software authenticate-developer

mpittcasd
Contributor

Thanks for all the tips everyone. I did eventually get the PKG from the AppStore downloads folder and tried to set it up in the policy I used for Xcode 8. When I ran the policy through Self Service to test it seemed to hang, but at the same time I think two other laptops checked in and got it successfully.