IOS displays version, Build, Git and more in system settings

Source: Internet
Author: User

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&gt ; 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

      1. If not, Run Script increase in the upper left corner of the area + ;
      2. Copy and paste the script from step 3.

Ok! Complete!

IOS displays version, Build, Git and more in system settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.