1.添加脚本
图1.Xcode界面在脚本里写下代码:
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
# buildNumber=$(($buildNumber + 1))
buildNumber=`date +\%Y-\%m-\%d\ \%H:\%M:\%S`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
2.代码中获取时间
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
网友评论