Receigen provides a way to integrate directly into the Xcode build process. The integration is done with a custom build phase, that generates the validation code if needed in a transparent way.

Go the Editor > Add Build Phase and lick on the Add Run Script Build Phase item.

Rename the new Build Phase to identify it easier.

Then, move it before the Compile Sources phase, so the generation occurs before the sources are compiled.

The custom build phase contains a script that will check if the generation is needed, and if yes, the script will call the Receigen application.

The example below shows how to proceed to generate the receipt validation. Please note that it contains lines for both OS X and iOS, so you have to remove the irrelevant lines. Then paste the script in the custom build phase:

# Receigen binary
RECEIGEN="/Applications/Receigen.app/Contents/MacOS/Receigen"

# Extract Info.plist information
INPUT="$INFOPLIST_FILE"
BUNDLE_ID="$PRODUCT_BUNDLE_IDENTIFIER"
# On OS X, use CFBundleShortVersionString
BUNDLE_VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INPUT"`
# On iOS, use CFBundleVersion
BUNDLE_VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$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
    # On OS X, check CFBundleIdentifier and CFBundleShortVersionString
    SKIP=`egrep -q "CFBundleIdentifier.+:.+$EXPANDED_BUNDLE_ID" "$HEADER" && egrep -q "CFBundleShortVersionString.+:.+$EXPANDED_BUNDLE_VERSION" "$HEADER" && echo "YES"`
    # On iOS, check CFBundleIdentifier and CFBundleVersion
    SKIP=`egrep -q "CFBundleIdentifier.+:.+$EXPANDED_BUNDLE_ID" "$HEADER" && egrep -q "CFBundleVersion.+:.+$EXPANDED_BUNDLE_VERSION" "$HEADER" && echo "YES"`
fi

# Generate the header file if needed
if [ "x$SKIP" = "x" ]; then
    # On OS X, call Receigen with options
    "$RECEIGEN" --identifier "$EXPANDED_BUNDLE_ID" --version "$EXPANDED_BUNDLE_VERSION" --os osx > "$HEADER"
    # On iOS, call Receigen with options
    "$RECEIGEN" --identifier "$EXPANDED_BUNDLE_ID" --version "$EXPANDED_BUNDLE_VERSION" --os ios > "$HEADER"
fi

Of course, you may adapt the command line parameters in order to pass other options.

Add an output file $(DERIVED_FILES_DIR)/receipt.h. The output file will be placed in the derived sources folder so you don't need to explicitly add the result file into the project.

Then, you can import the generated header file in your project like any other include file.