如何在应用程序的设置包中显示应用程序版本修订版? [英] How can I display the application version revision in my application's settings bundle?

查看:159
本文介绍了如何在应用程序的设置包中显示应用程序版本修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序的设置包中包含应用程序版本和内部修订,如1.0.1(r1243)。

I would like to include the application version and internal revision, something like 1.0.1 (r1243), in my application's settings bundle.

Root.plist文件包含这样的片段......

The Root.plist file contains a fragment like this...

     <dict>
        <key>Type</key>
        <string>PSTitleValueSpecifier</string>
        <key>Title</key>
        <string>Version</string>
        <key>Key</key>
        <string>version_preference</string>
        <key>DefaultValue</key>
        <string>VersionValue</string>
        <key>Values</key>
        <array>
            <string>VersionValue</string>
        </array>
        <key>Titles</key>
        <array>
            <string>VersionValue</string>
        </array>
    </dict>

我想在构建时替换VersionValue字符串。

and I would like to replace the "VersionValue" string at build time.

我有一个脚本可以从我的存储库中提取版本号,我需要的是一种在构建时处理(预处理)Root.plist文件的方法,并替换修订版本数字而不影响源文件。

I have a script that can extract the version number from my repository, what I need is a way to process (pre-process) the Root.plist file, at build time, and replace the revision number without affecting the source file.

推荐答案

我设法通过使用pListcompiler( http://sourceforge.net/projects/plistcompiler )开源项目。

I managed to do what I wanted by using the pListcompiler (http://sourceforge.net/projects/plistcompiler) open source porject.


  1. 使用此编译器,您可以使用以下格式在.plc文件中编写属性文件:

  1. Using this compiler you can write the property file in a .plc file using the following format:

plist {
    dictionary {
        key "StringsTable" value string "Root"
        key "PreferenceSpecifiers" value array [
            dictionary {
                key "Type" value string "PSGroupSpecifier"
                key "Title" value string "AboutSection"
            }
            dictionary {
                key "Type" value string "PSTitleValueSpecifier"
                key "Title" value string "Version"
                key "Key" value string "version"
                key "DefaultValue" value string "VersionValue"
                key "Values" value array [
                    string "VersionValue"
                ]
                key "Titles" value array [
                    string "r" kRevisionNumber
                ]
            }
        ]
    }
}


  • 我有一个自定义运行脚本构建阶段,正在将我的存储库修订版提取到.h文件,如brad-larson 此处

    plc文件可以包含n预处理程序指令,如#define,#message,#if,#elif,#include,#warning,#ifdef,#else,#pragma,#error,#ifnf,#endif,xcode环境变量。所以我能够通过添加以下指令来引用变量kRevisionNumber

    The plc file can contain preprocessor directives, like #define, #message, #if, #elif, #include, #warning, #ifdef, #else, #pragma, #error, #ifndef, #endif, xcode environment variables. So I was able to reference the variable kRevisionNumber by adding the following directive

    #include "Revision.h"
    


  • 我还为我的xcode目标添加了一个自定义脚本构建阶段,以便每次项目构建时运行plcompiler

  • I also added a custom script build phase to my xcode target to run the plcompiler every time the project is beeing build

    /usr/local/plistcompiler0.6/plcompile -dest Settings.bundle -o Root.plist Settings.plc
    


  • 就是这样!

    这篇关于如何在应用程序的设置包中显示应用程序版本修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆