iosxcode

Auto Increment Build Version in IOS SwifUI program Using Date


I have a swiftUI application that I want to increase the build number automatically.

Issue is, no online solution seems to work.

Ive tried adding a build phase and modifying the Info.plist file (and all variations of this) but that doesn't work.

Root issue seems to be that the Info.plist isn't the source of truth. Adding fields to the plist doesn't update the .xcodeproj file. The only way I can modify the build number is by modifying targets > build settings > Current Project Version or targets > general > build

Ive tried creating an .xcconfig file and adding the CURRENT_PROJECT_VERSION. And that also doesn't work

Does anyone know what could be wrong?


Solution

  • Editing Info.plist doesn't work probably because the "Generate Info.plist File" build setting is turned on, causing the value of CFBundleVersion to be reset to the "Current Project Version" value from the build settings.

    To increment the "Current Project Version", simply run agvtool bump from the directory where the xcodeproj file resides.

    You can edit your schemes so that it runs a script like this

    cd "${PROJECT_DIR}" ; agvtool bump
    

    after each build.

    enter image description here

    enter image description here

    If you want to use the current date as the build number, you can do

    agvtool new-version $(date +%Y%m%d)