Increment bundle version for iOS App + Watch Extension


Probably a lot of iOS developers use automated scripts to increment their bundle version, as it it necessary for distribution. Since a year know I always used a bash script and included it in my apps Build Phase.
For the script I used the credits go to this guy Tommy Goode. For a more detailed description of the basic script see his article here.
I really like it because it forces you to also make commits to your repo, otherwise the number does not increase ;)

Now I noticed while working on a new App with an Apple Watch Extension, my script/build broke, because the Apple Watch App has its own Info.plist file and obviously wasn't updated. My iOS App Bundle version worked but the Watch App Bundle version stayed 1.
After a little bit of searching I found a really useful command to look into the Path settings XCode uses:

Show Build Settings: xcodebuild -project YourProject.xcodeproj/ -target "Your App Target" -showBuildSettings

This showed me all necessary path variables and I was able to create an updated script for both the Apple Watch Extension and the Watch App.

Include this script (needs to be in a subfolder called scripts) in your Apps Watch Extension Build Phase like in the Image:
Build Phase Screenshot

Now everything runs smoothly and updates my build numbers :)