xcode Info.plist 文件中的配置依赖值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8971488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configuration dependent value in Info.plist file
提问by Besi
I have three configurations in my iOS project:
我的 iOS 项目中有三个配置:
- Debug
- Adhoc
- Release
- 调试
- 特别指定
- 释放
Now I want to change the name of the App as follows:
现在我想更改应用程序的名称如下:
- MyAppDebug
- MyAppAdhoc
- MyApp(Note that this one does not have a suffix)
- 我的应用调试
- 我的应用程序临时
- MyApp(注意这个没有后缀)
Is there a way I can easily achieve this in Xcode with some type of "compiler-if-else-macro-thing"?
有没有一种方法可以在 Xcode 中使用某种类型的“compiler-if-else-macro-thing”轻松实现这一点?
回答by Youraj
Changing display name of app for respective configurations: one way to achieve this is by using the same info plist file that you have.
为相应的配置更改应用程序的显示名称:实现此目的的一种方法是使用您拥有的相同信息 plist 文件。
Part 1: create an user defined variable
第 1 部分:创建用户定义的变量
- Click on target project file.
- Then at bottom right corner locate button "+" Add Build Setting.
- Click that button "Add Build Setting" and select "Add User-Defined Setting" enter name for New Setting as for ex: "BUNDLE_DISPLAY_NAME".
- Expand this new setting to see the configurations under it. Give the desired name to be displayed for each configuration. For ex: Debug -> MyAppDebug
- 单击目标项目文件。
- 然后在右下角找到按钮“+”添加构建设置。
- 单击该按钮“添加构建设置”并选择“添加用户定义的设置”为新设置输入名称,例如:“BUNDLE_DISPLAY_NAME”。
- 展开此新设置以查看其下的配置。为每个配置指定要显示的所需名称。例如:调试 -> MyAppDebug
Part 2: use it
第 2 部分:使用它
- Select your appname-info.plist file.
- Locate key "Bundle Display Name" and value to it should be this new user defined variable ${BUNDLE_DISPLAY_NAME}
- 选择您的 appname-info.plist 文件。
- 找到键“Bundle Display Name”,它的值应该是这个新的用户定义变量 ${BUNDLE_DISPLAY_NAME}
Then for appropriate configuration it will select name from BUNDLE_DISPLAY_NAME variable in build settings.
然后为了适当的配置,它将从构建设置中的 BUNDLE_DISPLAY_NAME 变量中选择名称。
回答by gavrix
Sure. First you have to create separate Info.plist file each configuration. Then in you Project's build settings find the line where Info.plist is placed, expand that line and choose separate Info.plist file for each configuration you have. Then you can enter desired name in corresponding field in each Info.plist file. That's it :)
当然。首先,您必须为每个配置创建单独的 Info.plist 文件。然后在您项目的构建设置中找到放置 Info.plist 的行,展开该行并为您拥有的每个配置选择单独的 Info.plist 文件。然后您可以在每个 Info.plist 文件的相应字段中输入所需的名称。就是这样 :)