$(PROGRAM_NAME)
而不是
"My App Name"
...
Info.plist:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>${PRODUCT_NAME} would like to use your current location while using the app and in the background</string>
InfoPlist.strings (EN):
"NSLocationAlwaysAndWhenInUseUsageDescription" = "${PRODUCT_NAME} would like to use your current location while using the app and in the background";
InfoPlist.strings (FR):
"NSLocationAlwaysAndWhenInUseUsageDescription" = "${PRODUCT_NAME} souhaiteraient utiliser votre emplacement actuel en utilisant l'application et en arrière-plan";
基于此解决方案:Https://stackoverflow.com/a/27886342/8874833
我创建了一个自定义运行脚本并以这种方式进行调整:
My_app_name是Xcconfig
中的用户定义值
这里是一个适用于MacOS的版本(除了iOS和Visionos之外)。
for f in "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"/*.lproj/InfoPlist.strings; do
encoding=$(file --brief --mime-encoding "$f")
original_encoding=$encoding
if [ $original_encoding = binary ]; then
plutil -convert json "$f"
encoding=$(file --brief --mime-encoding "$f")
fi
iconv -f "$encoding" -t utf-8 < "$f" | sed -e "s/\$(PRODUCT_NAME)/${PRODUCT_NAME}/g" | iconv -f utf-8 -t "$encoding" > "$f~"
mv -f "$f~" "$f"
if [ $original_encoding = binary ]; then
plutil -convert binary1 "$f"
fi
done
iOS和Visionos字符串文件是二进制文件,因此我们需要先转换它们,但在MACOS上不转换它们,它们是UTF-8不喜欢的UTF-8,因此我们需要将它们转换为UTF-8。