In Settings, show custom content, such as circled area content
Steps:
1. Add a Settings.bundle file to your project
The source code for Root.plist is as follows:
<?xml version="1.0"encoding="UTF-8"? ><! DOCTYPE plist Public"-//apple//dtd PLIST 1.0//en" "HTTP://WWW.APPLE.COM/DTDS/PROPERTYLIST-1.0.DTD"><plist version="1.0"><dict> <key>PreferenceSpecifiers</key> <array> <dict> <key> ; Title</key> <string>info</string> <key>Type</key> <string>psgroupspecifier</string> </dict> <dict> <key>DefaultValue</key> <string>1.2.3</string> <key>Key</key> <string>version_preference</string> <key>Title</key> <string>version</string> <key>Type</key> <string>pstitlevaluespecifier</string> </dict> <dict> <key>DefaultValue</key> <string>20170725.1</string> <key>Key</key> <string>build_preference</string> <key>Title</key> <string>build</string> <key>Type</key> <string>pstitlevaluespecifier</string> </dict> <dict> <key>DefaultValue</key> <string>4993065</string> <key>Key</key> <string>githash_preference</string> <key>Title</key> <string>git</string> <key>Type</key> <string>pstitlevaluespecifier</string> </dict> </array> <key>StringsTable</key> <string>root</string></dict></plist>
3. Edit the script to set the value of the Settings.bundle
#获取VersionVersion=$ (/usr/libexec/plistbuddy-c"Print cfbundleshortversionstring" "${project_dir}/${infoplist_file}")/usr/libexec/plistbuddy-c"Set:P referencespecifiers:1:defaultvalue ${version}" "${project_dir}/${project_name}/settings.bundle/root.plist"#获取BuildBuild=$ (/usr/libexec/plistbuddy-c"Print cfbundleversion" "${project_dir}/${infoplist_file}")/usr/libexec/plistbuddy-c"Set:P referencespecifiers:2:defaultvalue ${build}" "${project_dir}/${project_name}/settings.bundle/root.plist"#获取Git当前git SHA1 value git= ' Git rev-parse-- ShortHEAD | Awk'{print $}'`/usr/libexec/plistbuddy-c"Set:P referencespecifiers:3:defaultvalue ${git}" "${project_dir}/${project_name}/settings.bundle/root.plist"
4. Configure the project script
Path:Target -> 项目名字 -> Build Phases
- If not,
Run Script
increase in the upper left corner of the area +
;
- Copy and paste the script from step 3.
Ok! Complete!
IOS displays version, Build, Git and more in system settings