显示应用程序的构建日期 [英] Showing App's Build Date

查看:124
本文介绍了显示应用程序的构建日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在模拟器中显示我的应用程序的构建日期,但每当我存档应用程序并将其上传到TestFlight,然后将其安装在设备上时,构建日期都不会显示。

I am able to display the build date for my app in the simulator, but whenever I archive the app, and upload it to TestFlight, and then install it on a device, the build date doesn't show.

这是我正在做的显示构建日期。

Here is what I'm doing to display the build date.

首先,我添加了 CFBuildDate 作为myproject-info.plist的字符串

First, I added CFBuildDate as a string to myproject-info.plist

接下来,我将以下脚本添加到Edit Scheme - > Build - > Pre-Actions - > Run Script Action:

Next, I added the following script to Edit Scheme -> Build -> Pre-Actions -> Run Script Action :

infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
builddate=`date`
if [[ -n "$builddate" ]]; then
/usr/libexec/PlistBuddy -c "Add :CFBuildDate $builddate" ${infoplist}
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $builddate" ${infoplist}
fi

最后,使用以下代码从plist文件中获取构建日期:

Finally, used the following code to get the build date from the plist file :

NSString *build_date = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];

这会在模拟器中显示构建日期(虽然偶尔也没有),但在部署应用程序时通过TestFlight,构建日期永远不会显示。有什么想法吗?

This displays the build date in simulator (though occasionally it doesn't), but when deploying the app through TestFlight, the build date never displays. Any ideas ?

提前致谢。

推荐答案

尝试运行脚本作为构建阶段步骤,而不是方案预执行步骤,因此无论您生成的构建类型如何,它都会一直运行。

Try running the script as a build phase step, rather than a scheme pre-action step, so it's run all the time, regardless of the type of build you are producing.

这篇关于显示应用程序的构建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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