Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Oct 3, 2019
0 parents commit 21a4bc3
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xcderiveddata
19 changes: 19 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2019 Read Evaluate Press, LLC

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
SHELL = /bin/bash

prefix ?= /usr/local
bindir ?= $(prefix)/bin
srcdir = src

.DEFAULT_GOAL = all

.PHONY: all
all: xcderiveddata

xcderiveddata: $(srcdir)/xcderiveddata.bash
@cp $< $@
@chmod +x $@

.PHONY: install
install: xcderiveddata
@install -d "$(bindir)"
@install xcderiveddata "$(bindir)"

.PHONY: uninstall
uninstall:
@rm -rf "$(bindir)/xcderiveddata"

.PHONY: clean
clean:
@rm -f xcderiveddata
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# xcderiveddata

A command-line utility that prints the path of the derived data directory
for the current Xcode project.

## Requirements

- Xcode

## Command-Line Usage

The `xcderiveddata` executable can be run from the command line
from any directory with an Xcode project:

```terminal
$ find . -name "*.xcodeproj" -maxdepth 1
MyApp.xcodeproj
$ xcderiveddata
~/Library/Developer/Xcode/DerivedData/MyApp-abcdefghijklmnopqr1234567890
```

Any additional arguments are passed to `xcodebuild`,
which can be used to set the target, scheme, and any other other options
for the specified project or workspace:

```terminal
$ find . -name "*.xc*" -maxdepth 1
MyApp.xcodeproj
MyFramework.xcodeproj
MyWorkspace.xcworkspace
$ xcderiveddata -workspace MyWorkspace.xcworkspace \
-scheme MyFramework
~/Library/Developer/Xcode/DerivedData/MyFramework-abcdefghijklmnopqr1234567890
```

> **Note**
> This command fails if any `xcodebuild` options are passed
> that are incompatible with the `-showBuildSettings` option.
### Installation

#### Homebrew

Run the following command to install using [homebrew](https://brew.sh/):

```terminal
$ brew install nshipster/formulae/xcderiveddata
```

#### Manually

Run the following commands to build and install manually:

```terminal
$ git clone https://github.com/NSHipster/xcderiveddata.git
$ cd xcderiveddata
$ make install
```

## License

MIT

## Contact

Mattt ([@mattt](https://twitter.com/mattt))
15 changes: 15 additions & 0 deletions src/xcderiveddata.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

if ! [ -x "$(command -v xcodebuild)" ]; then
echo 'Error: xcodebuild is not installed.' >&2
exit 1
fi

xcodebuild -showBuildSettings $@ |
grep -m 1 "BUILD_DIR" |
grep -oEi "\/.*" |
sed 's#/Build/Products##'

0 comments on commit 21a4bc3

Please sign in to comment.