我能够在模拟器中显示我的应用程序的构建日期,但是每当我将应用程序存档并将其上传到 TestFlight,然后将其安装到设备上时,构建日期都不会显示。
这是我为显示构建日期所做的工作。
首先,我将 CFBuildDate 作为字符串添加到 myproject-info.plist
接下来,我在 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 文件中获取构建日期:
NSString *build_date = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];
这会在模拟器中显示构建日期(虽然偶尔不会),但是当通过 TestFlight 部署应用程序时,构建日期永远不会显示。有什么想法吗?
提前致谢。
最佳答案
您可以考虑使用内置的 __DATE__
和 __TIME__
宏,它们将返回应用构建日期和时间的字符串表示形式。也许他们会对你有更多帮助:
NSString *dateStr = [NSString stringWithUTF8String:__DATE__];
NSString *timeStr = [NSString stringWithUTF8String:__TIME__];
https://stackoverflow.com/questions/11779403/
相关文章:
linux - 在 Debian 或 Ubuntu 下自动获取构建依赖项的 Debian 方式是什么
php - 在 ubuntu 上构建 php5.3.8,得到错误 : configure: erro
android - 使用-sdk :minSdkVersion 15 cannot be small
javascript - 通过 grunt 任务更新 json 文件中的文件引用
makefile - cmake和并行构建与 "make -jN"
build - 如何在 VSTS/VSO Build vNext 中创建 Web 部署包?
android - 指示 Android Gradle 脚本删除未对齐的 apk 并清理 Artif