Skip to content

Instantly share code, notes, and snippets.

@letiemble
Created August 23, 2013 19:21
Show Gist options
  • Save letiemble/6322996 to your computer and use it in GitHub Desktop.
Save letiemble/6322996 to your computer and use it in GitHub Desktop.
When developing inside Xcode, use this script inside a "Run Script" build phase and place it before the "Compile Sources" one.
# Receigen binary
RECEIGEN="/Applications/Receigen.app/Contents/MacOS/Receigen"
# Extract Info.plist information
INPUT="$INFOPLIST_FILE"
BUNDLE_ID=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$INPUT"`
BUNDLE_VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INPUT"`
# Expand information if needed
EXPANDED_BUNDLE_ID=`eval "echo $BUNDLE_ID"`
EXPANDED_BUNDLE_VERSION=`eval "echo $BUNDLE_VERSION"`
# Make sure the destination directory exists
mkdir -p "$DERIVED_FILES_DIR"
HEADER="$DERIVED_FILES_DIR/receipt.h"
# Check if the generation is needed
if [ -e "$HEADER" ]; then
SKIP=`grep -q "$EXPANDED_BUNDLE_ID" "$HEADER" && grep -q "$EXPANDED_BUNDLE_VERSION" "$HEADER" && echo "YES"`
fi
# Generate the header file if needed
if [ "x$SKIP" = "x" ]; then
"$RECEIGEN" --identifier "$EXPANDED_BUNDLE_ID" --version "$EXPANDED_BUNDLE_VERSION" --type receipt > "$HEADER"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment