Xcode 11 archive gives PhaseScriptExecution failed

前端 未结 4 851
小鲜肉
小鲜肉 2021-01-04 21:59

After I migrate my project from swift 3.2 to swift 4 in Xcode 10 I try to archive in Xcode 11 and give me this error:

PhaseScriptExecution Run\\ Scrip

相关标签:
4条回答
  • 2021-01-04 22:08

    Just change CFBundleVersion from $(CURRENT_PROJECT_VERSION) to number, in my case is 1000 in Info.plist

    <key>CFBundleVersion</key>
    <string>1004</string>
    

    Then the shell will be OKey:

    buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
    buildNumber=$(($buildNumber + 1))
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
    
    0 讨论(0)
  • 2021-01-04 22:08

    Here is the script that worked for me on Xcode 11+
    Just add a new Run Script Phase to your Build Phases
    Add it below the Link Binary with Libraries phase.

    #!/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 
    

    This script was originally posted here by Alex Zavatone.

    Hope this helps

    0 讨论(0)
  • 2021-01-04 22:27

    UPDATE 2:

    This causes builds to be canceled! Have a look at S1LENT WARRIOR's answer below, it seems to be working better.

    UPDATE 1:

    In the latest version of Xcode (Version 11.1) you can do the build number auto increment fairly easily.

    Here are the steps:

    1. Go to your target's Build Settings
    2. Search for Versioning System
    3. Set it's value to Apple Generic
    4. Go to your target's Build Phases
    5. Add a new Run Script
    6. Add the following line agvtool next-version -all

    Do this for all your targets and their build numbers will all be synced and updated every time you run any of the targets.

    Got this answer from here: https://stackoverflow.com/a/58237340/1432355

    P.S.: As said in a comment below

    Using avgtool in a Run Script Phase causes the build to get cancelled

    ORIGINAL:

    You didn't do anything wrong I think.

    If you go to your info.plist you will see that the build number has been replaced by $(CURRENT_PROJECT_VERSION) (you can find the variable in the Build Settings tab).

    I am guessing you are using a script that increments build number automatically and that is causing the issue (I have the same thing on my project right now).

    If you remove that script your app should build without this error.

    I haven't found a solution yet on how to make the script work with this new $(CURRENT_PROJECT_VERSION) variable. (I will update this answer when I have found the solution)

    0 讨论(0)
  • 2021-01-04 22:30

    All the above answers weren't doing the trick by themselves, I had to compute a bunch of them, including the Apple documentation (see references below). So here are the steps I did if it helps someone to have all the steps.

    In Info.plist, set:

    • CFBundleShortVersionString to $(MARKETING_VERSION)
    • CFBundleVersion to $(CURRENT_PROJECT_VERSION)

    In target build settings:

    • set Versioning System to "Apple Generic"
    • set Current Project Version to 1 (or whatever version you want)
    • set Marketing Version to 1.0.0 (or whatever version you want)

    In the scheme > Archive:

    • add a post-action "Run Script Action":
      • Provide build settings from: your app
      • in the script: cd ${PROJECT_DIR} ; xcrun agvtool next-version -all ;

    1. Apple doc mentioned by cuimingda : https://developer.apple.com/library/archive/qa/qa1827/_index.html
    2. Some of the steps mentioned by moucheg
    0 讨论(0)
提交回复
热议问题