![](/img/trans.png)
[英]Use conditional to change variable based on info.plist environment key
[英]How to change an Info.plist flag based on the TARGET_OS?
我試圖遷移我的iOS應用程序以支持UIKitForMac
目標(項目Catalyst! )的構建。
我正在嘗試基於TARGET_OS
更改Info.plist
標志,但是我不確定如何從構建階段的運行腳本中檢測目標OS。 這是我想要做的:
echo "[DEBUG-PRINT] ---> Update flag"
if [ ${TARGET_OS_UIKITFOTMAC} ]; then
echo "[DEBUG-PRINT] ---> IF succeeded"
/usr/libexec/PlistBuddy -c "Set :LSSupportsOpeningDocumentsInPlace YES" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
我究竟做錯了什么? 有任何想法嗎?
我最終在方案中添加了行動前運行腳本:
#!/bin/sh
INFO_PLIST="$INFOPLIST_FILE"
RAW_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST")
if [[ $OTHER_SWIFT_FLAGS == *"-D TARGET_OS_UIKITFORMAC"* ]] && [[ $RAW_BUNDLE_ID != uikitformac* ]]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier uikitformac.$RAW_BUNDLE_ID" "$INFO_PLIST"
elif [[ $OTHER_SWIFT_FLAGS != *"-D TARGET_OS_UIKITFORMAC"* ]] && [[ $RAW_BUNDLE_ID == uikitformac* ]]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${RAW_BUNDLE_ID#'uikitformac.'}" "$INFO_PLIST"
fi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.