Skip to content

Conversation

@interstateone
Copy link
Contributor

@interstateone interstateone commented Dec 31, 2020

This adds a directory argument at the top level (so it affects all commands) which determines the directory that xcodes installs in to. It defaults to /Applications, which is the current behaviour. xcodes will also check for a value in the XCODES_DIRECTORY environment variable. It applies to installation but also the other commands, so that e.g. selecting or uninstalling a version looks in the desired directory.

The motivation for all of this is to support users that may not want to store Xcode versions in /Applications, for example if they don't have enough space on their boot volume.

This also aligns with the addition of the directory argument as part of #121.

Testing

First, clone this repo if necessary and check out the PR branch:

git clone https://github.com/RobotsAndPencils/xcodes.git
cd xcodes
git checkout -b interstateone-xcodes-destination master
git pull https://github.com/interstateone/xcodes.git xcodes-destination

then run commands with either the directory argument or XCODES_DIRECTORY environment variable set. If it's set to a directory that doesn't exist, or to a path that isn't a directory, it should print an error.

Expected results:

❯ swift run xcodes list --directory /Users/brandon/Xcodes
Directory argument must be a directory, but was provided /Users/brandon/Xcodes.

# make sure the directory exists
❯ mkdir /Users/brandon/Xcodes

# it doesn't have any Xcodes in it yet
❯ swift run xcodes installed --directory /Users/Brandon/Xcodes

# download command still works like before
❯ swift run xcodes download 12.3 --directory /Users/brandon/Xcodes
(1/1) Downloading Xcode 12.3.0: 99%

Xcode 12.3.0 has been downloaded to /Users/brandon/Xcodes/Xcode-12.3.0.xip

❯ ls /Users/brandon/Xcodes | grep Xcode                               
-rw-r--r--   1 brandon  staff    11G  2 Jan 11:19 Xcode-12.3.0.xip

# install works
❯ XCODES_DIRECTORY=/Users/brandon/Xcodes swift run xcodes install 12.2                                  
(1/6) Downloading Xcode 12.2.0: 99%
(2/6) Unarchiving Xcode (This can take a while)
(3/6) Moving Xcode to /Users/brandon/Xcodes/Xcode-12.2.0.app
(4/6) Moving Xcode archive Xcode-12.2.0.xip to the Trash
(5/6) Checking security assessment and code signing
(6/6) Finishing installation
xcodes requires superuser privileges in order to finish installation.
macOS User Password: 

Xcode 12.2.0 has been installed to /Users/brandon/Xcodes/Xcode-12.2.0.app

❯ ls /Users/brandon/Xcodes | grep Xcode
drwxr-xr-x   3 brandon  staff    96B 23 Oct 20:24 Xcode-12.2.0.app
-rw-r--r--   1 brandon  staff    11G  2 Jan 11:19 Xcode-12.3.0.xip

Closes #100

@csykes csykes self-requested a review January 2, 2021 21:32
Copy link
Contributor

@csykes csykes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally using ENV variable + command line option

@csykes csykes merged commit 8c5f17b into XcodesOrg:master Jan 2, 2021
@interstateone interstateone deleted the xcodes-destination branch January 2, 2021 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom Xcode install location

2 participants