iOS应用程序中的构建信息(日期/时间应用程序已构建) [英] Build information in iOS Application (date/time app was built)

查看:111
本文介绍了iOS应用程序中的构建信息(日期/时间应用程序已构建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在iOS应用程序的构建过程中动态添加关于应用程序的信息的方法。

I'm looking for a way to dynamically add in information about the application during the build process of an iOS application.

在测试期间,知道我已经在我的设备上安装的应用程序是否被构建,并且可能谁构建它将是一个好知道。

During testing, it would be great to know when the application I have installed on my device was built and possibly who built it would be a good to know as well.

我在设置中设想一个部分。应用程序,将提供基本的构建信息进行调试的目的。我不想在每次构建之前手动更新构建信息文件 - 数据应该动态生成。

I'm envisioning a section in settings.app that would give basic build information for debugging purposes. I don't want to have to manually update a build information file before each build - the data should be generated dynamically.

推荐答案

您可以在Xcode中编写一个shell脚本构建阶段,该阶段在构建过程结束时运行。在此阶段,您可以使用 defaults 命令将数据写入任意文件。我使用这种技术写入Info.plist文件,但你可以写任何你想要的文件[1]。

You can write a shell script build phase in Xcode that runs at the end of your build process. In this phase you can use the defaults command to write data to an arbitrary file. I've used this technique to write to the Info.plist file, but you can write to any file you want[1].

这里是一个示例脚本写当前git版本到Info.plist:

Here's a sample script to write the current git version to Info.plist:

infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
gitversion="$(cd "$SRCROOT" && git describe --always --dirty 2>/dev/null)"
if [[ -n "$gitversion" ]]; then
    defaults write "${infoplist%.plist}" GitVersion "$gitversion"
fi

您应该能够根据需要指定文件(例如您的设置包)并编写所需的信息。

You should be able to adapt this to point to the file you want (e.g. your Settings bundle) and write the info you want.

[1]注意,如果你写信给Info.plist,Xcode有错误,可以阻止它实现Info.plist在构建过程中更改,这可能会破坏设备制作时的设置。

[1] Be careful if you write to Info.plist, Xcode has bugs that can prevent it from realizing Info.plist changed during the build, which can break the provisioning when doing a device build.

这篇关于iOS应用程序中的构建信息(日期/时间应用程序已构建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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