美文网首页初见
Xcode工程打包时 Build Number 自动加1

Xcode工程打包时 Build Number 自动加1

作者: UninhibitedSoul | 来源:发表于2018-10-12 14:24 被阅读23次

    tags: Xcode, 日常技巧

    今天打包发版时, 忽然想到为啥我要手动去改版本号呢?
    于是我 google 了一下, 找到一个解决办法, 是通过添加一个脚本的方式实现。
    原文链接 Increase the build number while Archiving in Xcode

    以下是精简版说明:

    1. TARGETS -> [your project] -> Build Phases -> +
    2. Select New Run Script Phase
    3. Copy this entire script in the provided blank space.
    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}"
    
    • Check the Run script only when installing item. If you want this script to increment build number only while archiving project.
    • Uncheck the Run script only when installing item. If you want to increment build number every time you run the project.

    相关文章

      网友评论

        本文标题:Xcode工程打包时 Build Number 自动加1

        本文链接:https://www.haomeiwen.com/subject/fhqgaftx.html