[译]教程:从 RAD Studio 中自定义你的 info.plist 文件

 

RAD Studio writes some options of your applications for OS X or iOS to a file, *.info.plist, which is included in your final application package when you deploy your application to OS X or iOS. This file defines things such as the version code or display name of your application, the list of capabilities that your application requires, and so on.

RAD Studio  为你的 OSX 或 iOX 选项到一个文件:*.info.plist,在你发布你的应用到 OS X 或 iOS时,它包含在你的最终应用包中。这个文件定义了一些类似于你应用的版本代号、显示名称、兼容性等等信息。

Usually, you do not need to touch this file, and you can let RAD Studio take care of everything for you. However, RAD Studio allows you to customize the content of the *.info.plist file if you need to include custom data in this file that you cannot define visually in your project options.

通常,你不需要触碰这个文件,你可以让 RAD Studio 来为你关注这一切。然而,在你需要在这个文件中包含不能在 工程选项中可视化定义的自定义的数据时,RAD Studio 允许你自定义 *.info.plist 文件里的内容。

When you deploy an application to the OS X or iOS target platforms for the first time, RAD Studio adds a file to your project folder: info.plist.TemplateOSX.xml or info.plist.TemplateiOS.xml. Whenever you deploy your application to OS X or iOS, RAD Studio reads the corresponding file, replaces some placeholders in the file with actual values from your project options, and writes the resulting content into an output file: <platform>\<build configuration>\*.info.plist. This output file is the *.info.plist file that is included in the application package that RAD Studio generates when you deploy your application to the OS X or iOS target platforms.

当你第一次发布一个应用到 OS X 或 iOS 目标平台,RAD Studio 在你的工程目录下添加一个文件:info.plist.TemplateOSX.xml 或 info.plist.TemplateiOS.xml。每当你发布你的应用到 OS X 或 iOS,RAD Studio 读取相应的文件,替换文件中的占位符为你工程选项的真正值,然后写入结果内容到一个输出文件<platform>\<build configuration>\*.info.plist。当你发布你的应用到 OS X 或 iOS 目标平台时, 这个输出文件包含了在了生成的应用包中。

To customize the output *.info.plist file of a single project, edit the content of info.plist.TemplateOSX.xml or info.plist.TemplateiOS.xml in the project folder.

要自定义单个工程输出的 *.info.plist,编辑工程目录下的 info.plist.TemplateOSX.xml or info.plist.TemplateiOS.xml。

The template files that RAD Studio adds to a project when you deploy that project to the OS X or iOS target platforms for the first time comes from the corresponding file in C:\Users\<username>\AppData\Roaming\Embarcadero\BDS\18.0. If you want your new projects to have a different starting template file, edit this file.

RAD Studio 在你第一次发布工程到 OS X 或 iOS 目标平台时,从  C:\Users\<username>\AppData\Roaming\Embarcadero\BDS\18.0 添加相应的模板文件。如果你想要新工程使用一个不同的模板文件,编辑这个文件。

Re-creating the info.plist Template Files

重建 info.plist 模板文件

The info.plist template file that RAD Studio generates can change from one version of RAD Studio to another. To deploy a project that was originally deployed with a different version of RAD Studio, be especially careful with the existing info.plist template files from your project folder.

RAD Studio 生成的 info.plist 模板文件可以从一个版本的 RAD Studio 变更到另一个。要发布一个使用不同版本的 RAD Studio 的工程,要特别注意你工程文件夹下已有的 info.plist。

There are two possible scenarios:

有两种可能的情况:

  • You want to keep the old info.plist template files because they are customized.
    因为它被自定义过,所以你想要保留旧的 info.plsit 模板文件。
  • You do not need to keep the old info.plist template files.
    你不需要保留旧的 info.plist 模板文件。

Keeping the info.plist Template Files

保留 info.plist 模板文件

You might want to keep your info.plist template files if you manually did modifications to them. In this case, you need to follow these steps:

如果你手动修改了它们,你可能想保留你的 info.plist 模板文件。这种情况下,你需要按下述步骤来:

  • Open your project folder.
    打开你的工程目录。
  • Be sure to back up your info.plist template files.
    确认备份你的 info.plist 模板文件。
  • Delete the info.plist template files from the project folder.
    从工程目录中删除 info.plist
  • Open your project with the new version of RAD Studio.
    用新版本 RAD Studio 打开你的工程
  • For each affected target platform (OS X, iOS Device – 32 bit, iOS Device – 64 bit and iOS Simulator):
    对于每个受影响的目标平台(OS X、iOS Device – 32 bit、iOS Device – 64 bit 和 iOS Simulator):

    • Select the target platform node on the Project Manager.
      在工程管理器中选择目标平台结点。
    • Deploy your project to the selected target platform.
      发布你的工程到选中的目标平台。
      Note: Deploying your project creates a new info.plist template file for the selected target platform.
      备注:发布你的工程会为选中的目标平台创建一个新的 info.plist 模板文件。
    • Go to your project folder to check that there is a new info.plist template file.
      到你的工程目录下,检查不否存在一个新的 info.plist 模板文件。
    • Manually add your changes to the new info.plist template file.
      手动添加你的变更信息到新的 info.plist 模板文件。

Creating a New info.plist Template Files

创建一个新的 info.plist 模板文件

If you did not modify the info.plist template files, follow these steps to let RAD Studio create new files:

如果你没有修改过 info.plist 模板文件,下面的步骤让 RAD Studio 创建一个新的文件:

  • Open your project folder.
    打开你的工程目录。
  • Delete the info.plist template files from the project folder.
    从工程目录中删除 info.plist
  • Open your project with the new version of RAD Studio.
    用新版本 RAD Studio 打开你的工程
  • For each affected target platform (OS X, iOS Device – 32 bit, iOS Device – 64 bit and iOS Simulator):
    对于每个受影响的目标平台(OS X、iOS Device – 32 bit、iOS Device – 64 bit 和 iOS Simulator):

    • Select the target platform node on the Project Manager.
      在工程管理器中选择目标平台结点。
    • Deploy your project to the selected target platform.
      发布你的工程到选中的目标平台。
      Note: Deploying your project creates a new info.plist template file for the selected target platform.
      备注:发布你的工程会为选中的目标平台创建一个新的 info.plist 模板文件。
    • Go to your project folder to check that there is a new info.plist template file.
      到你的工程目录下,检查不否存在一个新的 info.plist 模板文件。

Contents of the info.plist Template Files

info.plist 模板文件内容

The info.plist template files contain two placeholders that RAD Studio replaces by key-value pairs during the deploying applications overview. The following value indicates which info.plist keywords replace each placeholder:

info.plist 模板文件包含两个 RAD Studio 在发布应用时通过键值来替换的占位符。下面的值标记了那些要被替换的 info.plist 占位符关键词。

  • <%VersionInfoPListKeys%>
    Keywords defined on the Version Info page.
    在 Version Info 页定义的关键词。
  • <%ExtraInfoPListKeys%>
    • Keywords about artwork, based on the information on the Application page.
      artwork 相关的关键词,基于 Application 页上的信息。
    • For iOS:
      对于 iOS:

      • Keywords about orientation support, based on the information on the Orientation page.
        关于方向支持的关键词,基于 Orientation 页的信息。
      • Keywords for disabling the APS feature if the “Enable HTTP protocol requests” feature is disabled in the Entitlement List page.
        如果”Enable HTTP protocol requests” 功能在 Entitlement List 页被禁用,禁止 APS 功能的关键词。
      • CFBundleShortVersionString, based on the value of the corresponding fields in the Version Info page.
        CFBundleShortVersionString,基于 Version Info 页上相应的值。
      • UIRequiredDeviceCapabilities is “arm64” for iOS Device – 64 bit or “armv7” for other platforms.
        对于 iOS Device – 64 bit  ,UIRequiredDeviceCapabilities 的值为 “arm64″,否则是 “armv7″。
      • For iOS device platforms:
        对于 iOS 设备平台:

        • CFBundleSupportedPlatforms is “iPhoneOS”.
          CFBundleSupportedPlatforms 是 “iPhoneOS”。
        • CFBundleResourceSpecification is “ResourceRules.plist” (RAD Studio generates this file).
          CFBundleResourceSpecification 是 “ResourceRules.plist” (RAD Studio 生成此文件)。
        • MinimumOSVersion is the value configured for the “Minimum iOS version supported” option in the following options page:
          MinimumOSVersion 是在下面的选项页中配置的 “Minimum iOS version supported” 值:

          • Delphi: Project > Options > Delphi Compiler > Linking
          • C++: Project > Options > C++ Linker
        • For the Application Store platform configuration:
          对于应用商店平台配置:

          • DTPlatformName is “iphoneos”.
            DTPlatformName 为”iphoneos”。
          • The values for DTPlatformBuild and DTXcodeBuild depend on the SDK that you use to build your application.
            DTPlatformBuild 和 DTXcodeBuild 的值,取决于你构建应用的 SDK。
分享到:

0 条评论

沙发空缺中,还不快抢~