1, demand explanation
2, Procedure
2.1 New Script, select the Build Phases
![](https://img2018.cnblogs.com/blog/1213778/201812/1213778-20181229172955298-2110075255.png)
2.2 Click the plus sign and select New Run Script Phase
![](https://img2018.cnblogs.com/blog/1213778/201812/1213778-20181229173002068-778530837.png)
2.3 for easy identification, double rename Dynamic Build Version
![](https://img2018.cnblogs.com/blog/1213778/201812/1213778-20181229173218719-49528386.png)
2.4 Paste the following code, note the contents to be modified
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${$(SRCROOT)}/${INFOPLIST_FILE}")
buildNumber=`date +"%Y%m%d%H%M"`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
2.5 code runs acquisition
![](https://img2018.cnblogs.com/blog/1213778/201812/1213778-20181229172714338-1665629494.png)
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
NSLog(@"app_build == %@", app_build);
- So far, the project can also be seen in the compiled version is modified
![](https://img2018.cnblogs.com/blog/1213778/201812/1213778-20181229172825855-34650492.png)