Versioning breaks with cocoapods...

For years I have had a run script (below) that increments my builds for me. I recently switched to using coocapods for my sdk's. Now having the run script makes the build fail with error.


line 3: $(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1")

Command PhaseScriptExecution failed with a nonzero exit code



buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"



Thoughts?

Accepted Reply

Hilarious that I have looked and looked and tried virtually everything for about a month to fix this and the moment I post it in the forums, I figure it out. For whatever reason if your "Bundle Version" entry in your plist contains this: "$(CURRENT_PROJECT_VERSION)" then it won't work. It must contain a number. Then it works fine.

Replies

Hilarious that I have looked and looked and tried virtually everything for about a month to fix this and the moment I post it in the forums, I figure it out. For whatever reason if your "Bundle Version" entry in your plist contains this: "$(CURRENT_PROJECT_VERSION)" then it won't work. It must contain a number. Then it works fine.

if your "Bundle Version" entry in your plist contains this: "$(CURRENT_PROJECT_VERSION)" then it won't work


You mean, your increment script won't work.

But just having $(CURRENT_PROJECT_VERSION) in the plist works OK.

If these three things are true then the build fails:

1. CocoaPods installed

2. Plist contains $(CURRENT_PROJECT_VERSION) for "Bundle Version"

3. Common Run Script installed for incrementing builds


Having CocoaPods installed and having a Run Script installed seems to be very common.

I am experiencing this in 2022. I opened an old project who uses this $(CURRENT_PROJECT_VERSION) and it is still not working - did you guys have any work around?

However there is a solution

https://blog.tjitjing.com/index.php/2021/09/auto-increment-build-number-in-xcode-11-xcode-12.html

Actually there is a solution:

https://blog.tjitjing.com/index.php/2021/09/auto-increment-build-number-in-xcode-11-xcode-12.html

  • Interesting decision - I can edit but not delete my post?

Add a Comment