If you’re an iOS developer and searched for appending -dev to the version and landed here, you likely won’t need any explanations as to why that would ever be necessary. So I won’t provide one.

Here’s how to add any post- or prefix to the app version through Xcode. Note that we’re talking about the CFBundleShortVersionString here.

Googleable solution

Create a script that adds the version number into the Info.plist.

This is the solution I saw most when I googled around, but I did not end up using it because it would cause the file to change and show up in git where I’d have to commit it or ignore it. Ignoring it would mean it wouldn’t update when I actually update the version number later. And committing it would mean I would have the -dev version committed which I also don’t want.

Alternative solution

The gist of the solution is to create a user-defined variable in the project settings, and set the version based on the DEBUG/RELEASE flag (also done through the project settings).

Then, we change the Info.plist “and” the targets ‘General’ tab to actually use the user defined variable instead of a version.

You will notice that changing this will automatically change the Info.plist value as well.

Multiple targets

If you have multiple targets, e.g. a Watch App, they need to share the same app version. In this case, we can just make the exact changes as with the main target.

Caching issues

When we change the version, it doesn’t actually update the version in the app! This is because the Info.plist is cached until we do a clean build. If we want to version to always update after changing, we need to add a script that automatically deletes the cached Info.plist file so that Xcode will rebuild it with the newly updated number.

To do this we simply add a build phase bash script.

And here’s the script for copy-pastability.

rm -f "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"

And that’s it.