Can't run auto increment build script

Viewed 321

I am trying to run a Run Script Phase in Xcode 11.4 to auto increment my build number.

#!/bin/bash
bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
bN=$((bN += 1))
bN=$(printf "%d" $bN)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"

When I build my project I get the following error:

/Users/Me/Library/Developer/Xcode/DerivedData/MyApp-dmbnskuxjhlbmpeciklnrsercgqx/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyApp.build/Script-E4D01FDD243BC0E2007311D3.sh: line 5: $(CURRENT_PROJECT_VERSION): syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION)") Command PhaseScriptExecution failed with a nonzero exit code

1 Answers

Open your Info.plist file related to the project, find the Bundle Version key and instead of $(CURRENT_PROJECT_VERSION) add any integer number, i.e. 1 (it should be starting point for incrementing the build number)

Related