8

I'm using Receigen for Apple receipt checking. I have integrated a script on my build process that generates the appropriate files for my project:

    # 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/receiptCheck.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" --failure 'exitwith173' --success 'runapplication' --os osx > "$HEADER"
fi

The problem with Xcode 7 is with this line:

BUNDLE_ID=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$INPUT"`

Because the BundleID on the new Xcode is on the build settings instead of Info.plist I believe the key on the build settings is $(PRODUCT_BUNDLE_IDENTIFIER)

Is there a way to extract the Bundle Id from the build settings on the script ?

Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
the Reverend
  • 12,305
  • 10
  • 66
  • 121
  • I'm seeing this too - did you find a solution? I believe it's the EXPANDED_BUNDLE_ID=`eval "echo $BUNDLE_ID"` that is failing. – Scotty Sep 14 '15 at 15:18
  • Haven't got an answer from Receigen support yet. But I believe its the other line where it is extracting the BundleID from the info.plist with the Plistbuddy tool. We need a way to extract the BundleID from the build settings. Let me know if you find a way please. – the Reverend Sep 14 '15 at 18:55

3 Answers3

8

You can just use the $PRODUCT_BUNDLE_IDENTIFIER instead of hardcoding the bundle id:

EXPANDED_BUNDLE_ID=$PRODUCT_BUNDLE_IDENTIFIER

(Note that there are no parentheses around PRODUCT_BUNDLE_IDENTIFIER).

You can then delete the line that starts with BUNDLE_ID= because it is no longer necessary.

Thorsten
  • 346
  • 3
  • 10
  • That worked thank you! Does it makes a difference if you write it between quotes as other script statements ? ex.: EXPANDED_BUNDLE_ID="$PRODUCT_BUNDLE_IDENTIFIER" – the Reverend Sep 23 '15 at 21:32
  • 1
    The quotes protect against spaces, so they shouldn't be necessary, because the bundle identifier should contain no spaces. It would be more in line with the other definitions with the spaces, though. – Thorsten Sep 24 '15 at 17:13
  • I am having the exact problem. My build is failing on a line like this: CFStringRef InAppValidation_str1 = @obfuscateCF@(""); But the fix here is not working for me. Anyone have any more tips? – Ty Jacobs Oct 09 '15 at 00:37
  • This is not the correct answer because, if you have a bundle identifier like f3nghuang.${PRODUCT_NAME:rfc1034identifier} - it would not work !. This will work only for simple cases wherein bundle identifier is hardcoded. – prabodhprakash Sep 20 '16 at 11:29
3

It's very easy :

BUNDLE_ID= xcodebuild -showBuildSettings | grep PRODUCT_BUNDLE_IDENTIFIER

echo $BUNDLE_ID

Abouluadi
  • 101
  • 1
  • 4
0

I've got the same problem. Here's a way to work around it. In the script, replace:

EXPANDED_BUNDLE_ID=eval "echo $BUNDLE_ID"

with

EXPANDED_BUNDLE_ID='com.foo.bar'

where com.foo.bar is my product bundle identifier. This lets Receigen compile, at least, so I can keep working.

mcgyver42
  • 56
  • 6