Xcode通知中心展示编译配置,及非Release打包警告

392 阅读1分钟

通过Xcode的pre|post-action功能,在Build或打包时通过脚本的方式检查提示环境配置. 注意 Provide build seetings from 选项选择自己的scheme 快捷键[shift] + [cmd] + [,]

截屏2021-03-26 下午3.24.57.png 通知

截屏2021-03-26 下午3.31.42.png 弹窗

方式一

#!/bin/sh
 

#输出内容到prebuild.log
# exec > "${PROJECT_DIR}/prebuild.log" 2>&1

#applescript引用环境变量
osascript -e 'tell app "Xcode" to display dialog "'${CONFIGURATION}'"'

xcschemeDir=${PROJECT_DIR}/Cicero_iOS.xcodeproj/xcshareddata/xcschemes/Cicero_iOS.xcscheme

config=$(xmllint --xpath "string(//Scheme/ArchiveAction/@buildConfiguration)" $xcschemeDir)

if [ $config != "Release" ]; then
   osascript -e 'tell app "Xcode" to display dialog "正在非Release打包!"'
fi

方式二

#输出内容到prebuild.log
# exec > "${PROJECT_DIR}/prebuild.log" 2>&1

#applescript引用环境变量
osascript -e 'tell app "Xcode" to display dialog "'${CONFIGURATION}'"'

if [ $CONFIGURATION != "Release" ]; then
   osascript -e 'tell app "Xcode" to display dialog "正在非Release打包!"'
fi