一、添加versionLb
二、New Run Script Phase
新增Script命名为Update Launch Version,输入shell script:
# 注意:Xcode 11与Xcode 10环境变量有变化
# Xcode 11
version=${MARKETING_VERSION}
if [ -z ${version} ]; then
# Xcode 10
version=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
fi
sed -i bak -e "/userLabel=\"versionLb\"/s/text=\"[^\"]*\"/text=\"版本号:$version\"/" $PROJECT_DIR/$PROJECT_NAME/Base.lproj/LaunchScreen.storyboard