Packaging Xcode 5.0.2

a_simmons
Contributor II

Would any body be able to assist I am wanting to package Xcode 5.0.2 with its components installed and make the users be in the developer group when they use the program.
I have used composer and captured the program, when its opened I get a prompt saying Xcode needs to install components. How have other people gone about this?

26 REPLIES 26

jwojda
Valued Contributor II

have you looked at the links in this thread?
https://jamfnation.jamfsoftware.com/discussion.html?id=8606

rtrouton
Release Candidate Programs Tester

To go along with the links provided in @jwojda][/url's link, I have a post on how I'm creating an Xcode 5.0.2 installer:

http://derflounder.wordpress.com/2013/11/17/building-a-grand-unified-xcode-5-0-2-installer-for-maver...

a_simmons
Contributor II

Thanks for the help. I managed to package Xcode 5.0.2, do you know of away to leave developer mode enabled?

hurtado
New Contributor

I wanted to follow-up with regards to this question as I followed the steps outlined by @rtrouton (thanks very much for putting all that work in) but I'm still getting the prompt about installing additional components when I first launch Xcode.

@a.simmons did you have to do anything else to clear that prompt or did you get that built into your package?

RobertHammen
Valued Contributor II

I haven't packaged Xcode 5.0.2, but in previous versions the additional tools were embedded into the app bundle...

hurtado
New Contributor

In my case, I tried grabbing the pkg via the method linked from @rtrouton's steps (pausing the App Store download and creating a link). I also tried manual installs from the Apple Developer site and downloading directly from the App Store, and all cases, I receive the prompt to "Install additional required components?"

I'm still testing things further, but thought if anyone had already worked out a solution, it would be helpful.

a_simmons
Contributor II

Hi Hurtado,

I was receiving the same message to "Install additional required components". I tried to package it a number of ways but still got the same message as you. I had one department needing the application for their labs and students don't have right to install the additional components. I didn't have much time to get it ready for the beginning of semester, so I put XCode with the components install on the base image for that department for now and will need to try to repackage it when I have time.

jwojda
Valued Contributor II

hurtado - same issue here.

rtrouton
Release Candidate Programs Tester

The additional components may be the Mobile Device installer. Information on installing this package is available here:

https://jamfnation.jamfsoftware.com/discussion.html?id=4034

hurtado
New Contributor

And it looks like 5.1 just dropped, so as good a time as any to try adding that piece in.

Thanks! I'll report back once I've tried it out.

hurtado
New Contributor

There were two packages listed in the /Applications/Xcode.app/Contents/Resources/Packages/ location and it worked in both 5.0.2 and 5.1 when I added both of them.

Here's the script I threw together that runs after the pkg installs.

Thanks all for the help!

#!/bin/sh

# Accept Xcode License

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

# Install Additional Components

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

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

jwojda
Valued Contributor II

thank you for the script. did you package with composer or something else?

charles_hitch
Contributor II

Just a heads up that Apple included a new feature with 5.1 that is supposed to install the additional components for your rather than you having to manually install packages. Release notes state that if you run Xcode from the command line with -installComponents flag it will install required device support packages and then quit. In our testing this pops a message up to the user which requires admin rights. Users without admin can try to click the button, but nothing happens. I went back to the manual install of the device support packages. If anyone gets -installComponents working let me know.

hurtado
New Contributor

@jwojda I packaged 5.1 + command line tools using @rtrouton's steps for v5.0.2 http://derflounder.wordpress.com/2013/11/17/building-a-grand-unified-xcode-5-0-2-installer-for-maver...

The postinstall script needed a few modifications to work with updated package names, specifically changing the reference to "Xcode 5.0.2.pkg" to "Xcode 5.1.pkg" and the new command line tools dmg which is for march 2014 instead of october 2013, though these names depend on what name you give the packages when you download/save them.

You could likely include my script (outside of the opening "#! /bin/sh" line) at the end of the postinstall script and it would probably give you an even cleaner policy in the JSS that just uses the pkg instead of a pkg and a script.

If I find the time, I may look to put a few more variables in at the top of the script to make it easier to find/update the package names for future updates.

jwojda
Valued Contributor II

I gotta be doing something wrong. I updated for the March 2014, and CLTools, added both as additional resources as absolute path, as well as my pkg file from 5.1. Ran the installer, and it seems to go through, but then errors out ...

Mar 12 10:19:52 ushofmc311065 installd[1044]: PackageKit: Executing script "./postinstall" in /private/tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC Mar 12 10:19:52 ushofmc311065 install_monitor[1248]: Temporarily excluding: /Applications, /Library, /System, /bin, /private, /sbin, /usr Mar 12 10:19:52 ushofmc311065 installer[1256]: PFPkg: No file found at path: /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg Mar 12 10:19:52 ushofmc311065 installd[1044]: ./postinstall: Mar 12 10:19:52 ushofmc311065 installer[1256] <Critical>: PFPkg: No file found at path: /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg Mar 12 10:19:52 ushofmc311065 installer[1256]: PFPackage::packageWithURL - can't instantiate package: /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg Mar 12 10:19:52 ushofmc311065 installd[1044]: ./postinstall: Mar 12 10:19:52 ushofmc311065 installer[1256] <Critical>: PFPackage::packageWithURL - can't instantiate package: /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg Mar 12 10:19:52 ushofmc311065 installd[1044]: ./postinstall: installer: Error the package path specified was invalid: '/tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg'. Mar 12 10:19:54 ushofmc311065 installd[1044]: ./postinstall: /dev/disk1 Apple_partition_scheme Mar 12 10:19:54 ushofmc311065 installd[1044]: ./postinstall: /dev/disk1s1 Apple_partition_map Mar 12 10:19:54 ushofmc311065 installd[1044]: ./postinstall: /dev/disk1s2 Apple_HFS /private/tmp/commandlinetools.A14W /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/postinstall: line 90: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild: No such file or directory Mar 12 10:22:01 ushofmc311065 installer[1316]: PFPkg: No file found at path: /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg Mar 12 10:22:01 ushofmc311065 installer[1316]: PFPackage::packageWithURL - can't instantiate package: /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg Mar 12 10:22:01 ushofmc311065 installd[1044]: ./postinstall: installer: Error the package path specified was invalid: '/Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg'. Mar 12 10:22:01 ushofmc311065 installer[1317]: PFPkg: No file found at path: /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg Mar 12 10:22:01 ushofmc311065 installer[1317]: PFPackage::packageWithURL - can't instantiate package: /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg Mar 12 10:22:01 ushofmc311065 installd[1044]: ./postinstall: installer: Error the package path specified was invalid: '/Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg'. Mar 12 10:22:02 ushofmc311065 install_monitor[1248]: Re-included: /Applications, /Library, /System, /bin, /private, /sbin, /usr Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: releasing backupd Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: allow user idle system sleep Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “Xcode 5.1.pkg”." UserInfo=0x7fd320d1eab0 {NSFilePath=./postinstall, NSURL=file://localhost/Library/Application%20Support/JAMF/Downloads/Xcode%205.1.pkg, PKInstallPackageIdentifier=com.mygreatcompany.pkg.Xcode51, NSLocalizedDescription=An error occurred while running scripts from the package “Xcode 5.1.pkg”.} { NSFilePath = "./postinstall"; NSLocalizedDescription = "An error occurred while running scripts from the package U201cXcode 5.1.pkgU201d."; NSURL = "file://localhost/Library/Application%20Support/JAMF/Downloads/Xcode%205.1.pkg"; PKInstallPackageIdentifier = "com.mygreatcompany.pkg.Xcode51"; } Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: Running idle tasks Mar 12 10:22:02 ushofmc311065 installer[1239]: install:didFailWithError:Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “Xcode 5.1.pkg”." UserInfo=0x7ff3e9c5d9b0 {NSFilePath=./postinstall, NSURL=file://localhost/Library/Application%20Support/JAMF/Downloads/Xcode%205.1.pkg, PKInstallPackageIdentifier=com.mygreatcompany.pkg.Xcode51, NSLocalizedDescription=An error occurred while running scripts from the package “Xcode 5.1.pkg”.} Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: Removing client PKInstallDaemonClient pid=1239, uid=0 (/usr/sbin/installer) Mar 12 10:22:02 ushofmc311065 installd[1044]: PackageKit: Done with sandbox removals Mar 12 10:22:03 ushofmc311065 installer[1239]: Install failed: The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.

stevewood
Honored Contributor II
Honored Contributor II

Double check to make sure the Xcode 5.1 file is named right. The installer is having trouble locating the file:

No file found at path: /tmp/PKInstallSandbox.4knXYg/Scripts/com.mygreatcompany.pkg.Xcode51.hFctYC/Xcode 5.1.pkg

When I had that error, it was because I had the file named something else.

I'm actually working on this right now myself. I downloaded Xcode from the Developer site and am dropping the .app file into Applications instead of running the .PKG file.

jwojda
Valued Contributor II

after much trial and error with the scripts (and eventually mapping the path in the logs to see what was actually being dumped into the folders vs what the script was calling) I found you're right Stevewood. a capital C needed to be added and a . needed to be removed. Ugh. Damn my lack of attention to detail for this stuff. and damn apple/packages/computers in general for not understanding what I mean, not necessarily what I tell it.

jwojda
Valued Contributor II

is there an easy way to tell if the mobile device stuff got installed? I checked the command line and apparently the system reports the CLTools are installed, but I can't find anything on the mobile devices.

hurtado
New Contributor

I guess this would be one advantage to not putting my additional script in with the Xcode package, but keeping it as a separate script in the JSS.

As a separate script, I see the following output when I look at the log for the policy in the computer history:

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.

Otherwise, the way I could tell that the Mobile Device packages installed was simply opening xcode and noting that I didn't get any prompts for admin credentials/additional components.

stevewood
Honored Contributor II
Honored Contributor II

I just finished getting 5.1 packaged along with the Command Line tools and the Simulators. I used the following two resources for gaining the knowledge on how to do so:

Rich's blog: http://goo.gl/VDdSDH

Tim Sutton's Blog: http://goo.gl/AzGl24

To get the Simulators to work, I had to update the PKG files to include the install-location information in the PackageInfo file. Following the steps that Tim explains, I used pkgutil to expand the PKG, changed the PackageInfo file, and then re-flatten into a true PKG file. I then added some lines to Rich's postinstall script to install the simulators.

The result is an Xcode 5.1 package that installs the app, installs the MobileDevice and MobileDeviceDevelopment packages, accepts the EULA, and adds the logged in user to the _developer group. This is exactly what I need to be able to deploy as a Self Service item, or as a login policy.

Here's the postinstall script:

#!/bin/bash

# Script to install the necessary components for Xcode to install and run without need of an admin user
#
# Script courtesy Rich Trouton (http://derflounder.wordpress.com/2013/11/17/building-a-grand-unified-xcode-5-0-2-installer-for-mavericks-and-mountain-lion/)
#
# and courtesy Tim Sutton (http://macops.ca/xcode-deployment-the-dvtdownloadableindex-and-ios-simulators/)
#
# Date:  12 March 2014
# Steve Wood (swood@integer.com)

# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')

# Determine working directory

install_dir=`dirname $0`

# Accept the EULA
# http://macops.ca/deploying-xcode-and-cli-tools-whats-new-in-xcode-5/

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

# Instlal mobile components
installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDevice.pkg -target /

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

########  Add user to Dev group  ########
# Need to setup developer mode and add logged in user to dev group
#########################################

/usr/sbin/DevToolsSecurity -enable

loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

dseditgroup -o edit -a $loggedInUser -t user _developer

#####  Now install Command Line Tools

if [[ ${osvers} -eq 8 ]]; then

#
# Installing the Xcode 5.1 Command Line Tools
#

# Specify location of Xcode command-line tools disk image

  TOOLS=$install_dir/command_line_tools_for_xcode_os_x_mountain_lion_march_2014.dmg

# Specify a /tmp/commandlinetools.XXXX mountpoint for the disk image

  TMPMOUNT=`/usr/bin/mktemp -d /tmp/commandlinetools.XXXX`

# Mount the latest command line tools disk image to /tmp/commandlinetools.XXXX mountpoint

  hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse -noverify -noautoopen

# Install the Xcode command line tools by searching the top directory of the
# mounted disk image and installing any installer package found. Only the
# Command Line Tools installer will be found by this search so it will be
# installed without having the specify the current installer package's name

  /usr/sbin/installer -dumplog -verbose -pkg "$(/usr/bin/find $TMPMOUNT -maxdepth 1 ( -iname *.pkg -o -iname *.mpkg ))" -target "$3"

# Clean-up

# Unmount the command line tools disk image from /tmp/commandlinetools.XXXX

  /usr/bin/hdiutil detach "$TMPMOUNT"

# Remove the /tmp/commandlinetools.XXXX mountpoint

  /bin/rm -rf "$TMPMOUNT"

fi

if [[ ${osvers} -eq 9 ]]; then

#
# Installing the Xcode 5.1 Command Line Tools
#

# Specify location of Xcode command-line tools disk image

  TOOLS=$install_dir/commandline_tools_os_x_mavericks_for_xcode__march_2014.dmg

# Specify a /tmp/commandlinetools.XXXX mountpoint for the disk image

  TMPMOUNT=`/usr/bin/mktemp -d /tmp/commandlinetools.XXXX`

# Mount the latest command line tools disk image to /tmp/commandlinetools.XXXX mountpoint

  hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse -noverify -noautoopen

# Install the Xcode command line tools by searching the top directory of the
# mounted disk image and installing any installer package found. Only the
# Command Line Tools installer will be found by this search so it will be
# installed without having the specify the current installer package's name

  /usr/sbin/installer -dumplog -verbose -pkg "$(/usr/bin/find $TMPMOUNT -maxdepth 1 ( -iname *.pkg -o -iname *.mpkg ))" -target "$3"

# Clean-up

# Unmount the command line tools disk image from /tmp/commandlinetools.XXXX

  /usr/bin/hdiutil detach "$TMPMOUNT"

# Remove the /tmp/commandlinetools.XXXX mountpoint

  /bin/rm -rf "$TMPMOUNT"

fi

# Now install the simulators

# iPhone Simulator 6.0

SIMULATOR=$install_dir/iPhone_Sim_6.0.pkg

/usr/sbin/installer -dumplog -verbose -pkg "$SIMULATOR" -target /

# iPhone Simulator 6.1

SIMULATOR=$install_dir/iPhoneSimulator_6.1.pkg

/usr/sbin/installer -dumplog -verbose -pkg "$SIMULATOR" -target /

# iPhone Simulator 7.0

SIMULATOR=$install_dir/iPhoneSimulator_7.0.pkg

/usr/sbin/installer -dumplog -verbose -pkg "$SIMULATOR" -target /

# If this is 10.9 must patch 6.1
# iPhone Simulator 6.1 Patch
if [[ ${osvers} -eq 9 ]]; then

    # iPhone Simulator 6.1 Patch

    SIMULATOR=$install_dir/iPhoneSimulator_6.1_Patch.pkg

    /usr/sbin/installer -dumplog -verbose -pkg "$SIMULATOR" -target /

fi

exit 0

Thanks to Rich and Tim for doing the heavy lifting!

Hope this helps someone.

Kumarasinghe
Valued Contributor

@stevewood
FYI:
For OS X 10.9 (Mavericks) Command Line Tools are built in to Xcode. So no need to install them manually.

jwojda
Valued Contributor II

the simulators are part of the xcode package or do they need to be downloaded seperately? I didn't see them on the Dev site.

stevewood
Honored Contributor II
Honored Contributor II

They are downloaded separately. If you read Tim's blog post:

http://macops.ca/xcode-deployment-the-dvtdownloadableindex-and-ios-simulators/

He walks through how you can find the URL for the downloads. He found it using Charles Web Proxy to figure out the URL of each download. I did the same, but you can also look at this file:

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

Which should give you the URLs for the CLI tools and for the simulators.

CarrieNZ
New Contributor III

Thanks hurtado for the script, ran it postflight and it works a treat for 5.1.1 :)

leegalan
New Contributor III

Yes, thank you @hurtado ! This script worked great for me as well with 6.2. I'm sure it will also work with 6.3.

antoinekinch
New Contributor III

Does this work for Xcode 8.2.1?