Unmatched parens in Archive process generated file

Apologies, I am a beginner in this. I’m trying to archive my iOS app but keep getting this error:

Command PhaseScriptExecution failed with a nonzero exit code

It lists an error based on unmatched parentheses in a generated file, 

<project>.build/Script-CEC03A37266E7CBC00D5745A.sh: line 4: unexpected EOF while looking for matching `"'

That file contains the following:

#!/bin/sh
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion "$PRODUCT_SETTINGS_PATH")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$PRODUCT_SETTINGS_PATH"

As you can see, the 2nd line has an odd parens(“).

I’ve tried making the 2nd line 

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PRODUCT_SETTINGS_PATH")

…which didn't work, the file gets overwritten. 

Running MacOS 11.5, Xcode 12.5.1

Thank you for any help.

Accepted Reply

It looks like you have added a "Run Script" Build Phase.

Your updated line 2 looks correct, and works for me.

However, you could try this for line 2:

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")

You could also try deleting the Run Script, and re-adding it.

Replies

It looks like you have added a "Run Script" Build Phase.

Your updated line 2 looks correct, and works for me.

However, you could try this for line 2:

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")

You could also try deleting the Run Script, and re-adding it.

THANK YOU, robnotyou! Deleting the Run Script solved my problem. I had not added that script, as my understanding of Xcode does not yet go that deep. Hopefully its absence will not create problems, but I can always recreate it with your mod if need be. Thanks again.