如何在我的infoplist.strings File中使用info.plist。 我正在尝试从info.plist中使用$ {product_name}变量,但在我的本地化infoplist.strings文件中使用它,该文件将在弹出通知时显示该应用程序名称。这甚至可能吗? ...

问题描述 投票:0回答:1
$(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/8874833enter image description here 我创建了一个自定义运行脚本并以这种方式进行调整:

xcode localization info.plist
1个回答
1
投票

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。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.