How to set CURRENT_PROJECT_VERSION in Xcode 8

前端 未结 3 445
悲哀的现实
悲哀的现实 2021-01-04 07:34

Since upgrading to Xcode 8, when I do a build with fastlane, I get the following error message:

There does not seem to be a CURRENT_PROJECT_VERSION ke

相关标签:
3条回答
  • 2021-01-04 07:49

    Don't. Modify the values in your app's info.plist file instead.

    This means not using agvtool (as I learned).

    Why? Over the years, Apple has come up with several manners of changing version and build numbers. Many of them are now outdated and poor practice. Changing CURRENT_PROJECT_VERSION modifies values within your project's project.pbxproj file and if you are running a distributed team, this will cause merge conflicts if the other half of the team tries to update and while they were asleep, you updated this internal value. If you are using pods, you'll get several more merge conflicts per pod that you add to the project.

    So, CURRENT_PROJECT_VERSION?

    Don't use it.

    Within the info.plist file are these keys.

    CFBundleVersion
    CFBundleShortVersionString
    

    Use CFBundleVersion for your app's build number. Use CFBundleShortVersionString for your app's version number.

    Use Plistbuddy to do it.

        <key>CFBundleShortVersionString</key>
        <string>3.0.7</string>
        <key>CFBundleVersion</key>
        <string>934</string>
    </dict>
    </plist>
    

    Try the script below.

    #!/bin/sh
    
    # To make executable, use: chmod u+x Build-Versioning-Scripts/Increment_Build_Number.sh
    # to locate your target's info.plist use
    # ${PRODUCT_SETTINGS_PATH}
    
    echo "----"
    echo "Info.plist for target: ${PRODUCT_SETTINGS_PATH}"
    
    buildNum=$(/usr/libexec/Plistbuddy -c "Print CFBundleVersion" "${PRODUCT_SETTINGS_PATH}")
    echo "Current build #: $buildNum"
    
    if [ -z "$buildNum" ]; then
    echo "No build number found in $PRODUCT_SETTINGS_PATH"
    exit 2
    fi
    
    buildNum=$(expr $buildNum + 1)
    echo "Build # incremented to: $buildNum"
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNum" "$PRODUCT_SETTINGS_PATH"
    echo "----"
    exit 0
    

    By adding this script to your build or archive process on your build machine, this will automatically update the app's build number. If you wish to increment your app's version number, change CFBundleShortVersionString (Bundle versions string, short) in the info.plist manually.

    0 讨论(0)
  • 2021-01-04 07:58

    you may try change project format ?

    I suggest you can change this xcode format version.

    0 讨论(0)
  • 2021-01-04 08:00

    Currently when you get that fastlane error, terminal logs redirects you to

    Automating Version and Build Numbers Using agvtool

    to understand what you need to do.

    Summary

    1. Enable agvtool.

      Build Settings > Current Project Version > $(CURRENT_PROJECT_VERSION)

      Build Settings > Versioning System > Apple Generic

    2. Set up your version and build numbers.

      Target > Info > Bundle versions string, short (CFBundleShortVersionString) > "your init version"

      Target > Info > Bundle version (CFBundleVersion) > "your init value"

    That helps me a lot.

    0 讨论(0)
提交回复
热议问题