项目因为一些原因需要打两个包,包名不同、GoogleService-Info.plist 也不同,经常忘记换文件导致打的包有问题,虽然不崩溃但是统计不到数据。写个 Script 加到 Build Phases 即可:
X_BUNDLE_ID=${PRODUCT_BUNDLE_IDENTIFIER}
G_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print BUNDLE_ID" "${PROJECT_DIR}/Mixin/Supporting Files/GoogleService-Info.plist")
if [ "$X_BUNDLE_ID" == "$G_BUNDLE_ID" ]; then
echo "success"
else
echo "error: Xcode bundle id is different from GoogleService-Info.plist."
exit 1
fi
如果包名不一致编译时就能发现!妈妈再也不担心打错包了!
网友评论