Info.plist文件中的配置相关值

时间:2023-02-05 14:06:14

I have three configurations in my iOS project:

我的iOS项目中有三个配置:

  1. Debug
  2. Adhoc
  3. Release

Now I want to change the name of the App as follows:

现在我想更改App的名称,如下所示:

  1. MyAppDebug
  2. MyAppAdhoc
  3. MyApp (Note that this one does not have a suffix)
  4. 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”轻松实现这一点?

2 个解决方案

#1


32  

  • 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文件。

    1. Create a user defined variable. Click on target project file.
    2. 创建用户定义的变量。单击目标项目文件。

    3. Then at bottom right corner locate button "+" Add Build Setting.
    4. 然后在右下角找到按钮“+”添加构建设置。

    5. Click that button "Add Build Setting" and select "Add User-Defined Setting" enter name for New Setting as for ex: "BUNDLE_DISPLAY_NAME".
    6. 单击“添加构建设置”按钮并选择“添加用户定义的设置”,输入新设置的名称,例如:“BUNDLE_DISPLAY_NAME”。

    7. Expand this new setting to see the configurations under it. Give the desired name to be displayed for each configuration. For ex: Debug -> MyAppDebug
    8. 展开此新设置以查看其下的配置。为每个配置提供所需的名称。例如:Debug - > MyAppDebug

Part 2:

  1. Select your appname-info.plist file.
  2. 选择您的appname-info.plist文件。

  3. Locate key "Bundle Display Name" and value to it should be this new user defined variable ${BUNDLE_DISPLAY_NAME}
  4. 找到关键字“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变量中选择名称。

#2


4  

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文件。然后在Project的构建设置中找到放置Info.plist的行,展开该行并为您拥有的每个配置选择单独的Info.plist文件。然后,您可以在每个Info.plist文件的相应字段中输入所需的名称。而已 :)

#1


32  

  • 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文件。

    1. Create a user defined variable. Click on target project file.
    2. 创建用户定义的变量。单击目标项目文件。

    3. Then at bottom right corner locate button "+" Add Build Setting.
    4. 然后在右下角找到按钮“+”添加构建设置。

    5. Click that button "Add Build Setting" and select "Add User-Defined Setting" enter name for New Setting as for ex: "BUNDLE_DISPLAY_NAME".
    6. 单击“添加构建设置”按钮并选择“添加用户定义的设置”,输入新设置的名称,例如:“BUNDLE_DISPLAY_NAME”。

    7. Expand this new setting to see the configurations under it. Give the desired name to be displayed for each configuration. For ex: Debug -> MyAppDebug
    8. 展开此新设置以查看其下的配置。为每个配置提供所需的名称。例如:Debug - > MyAppDebug

Part 2:

  1. Select your appname-info.plist file.
  2. 选择您的appname-info.plist文件。

  3. Locate key "Bundle Display Name" and value to it should be this new user defined variable ${BUNDLE_DISPLAY_NAME}
  4. 找到关键字“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变量中选择名称。

#2


4  

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文件。然后在Project的构建设置中找到放置Info.plist的行,展开该行并为您拥有的每个配置选择单独的Info.plist文件。然后,您可以在每个Info.plist文件的相应字段中输入所需的名称。而已 :)