Build information in iOS Application (date/time app was built)

自古美人都是妖i 提交于 2019-11-28 10:07:32

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].

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] 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.

You can also use standard macro __DATE__ which will result string like "Jun 25 1980" of course with proper current date of build.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!