git log --pretty=format:"%h" | head -1  | awk '{print $1}'

 

可以放到xcode  build setting  post run script 里面设置版本号。