IOS App icon versioning

Most apps have beta versions and AppStore official versions. Under normal circumstances, we cannot quickly determine the App installation environment, version number, branch, and code submitted. As a result, there is some confusion for testing and development, and problem positioning is not efficient enough. We can improve the efficiency of problem location in the test environment by adding important information to the App icon, which is referred to here as iOS icon versioning.

IOS icon versioning

How do I get the information about the icon to be overwritten

  • The App version number
  • Build version number
  • Branch name
  • Submit the hash value

In the PList file of App, you can directly extract relevant information through the PlistBuddy tool. The Git command line tool provides the rev-parse command, the Git probe tool, to obtain Git information. 1. Obtain the App version number: version=/usr/libexec/PlistBuddy -c “Print CFBundleShortVersionString” “${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}” 2. Build_num = /usr/libexec/plistbuddy -c “Print CFBundleVersion” “${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}” 3 Branch = Git rev-parse –abbrev-ref HEAD 4 Git rev-parse –short HEAD

Ii. How to cover key information on the App icon?

ImageMagic is the tool I use to process images from the command line, and it offers a lot of functionality. Make sure to install imageMagick and ghostScript first. Brew can be used to simplify the installation process: * 1. Install imageMagick

Brew install ghostScript 3. We can use the convert function. By specifying parameters, imageMagick overlays the text on top of the image. We can also set the bottom alignment and default height. ImageMagick (TM) is a free software for creating, editing and compositing images. It can read, convert and write pictures in a variety of formats. Image cutting, color replacement, application of various effects, image rotation, composition, text, straight lines, polygons, ellipses, curves, extension rotation attached to the image.

How to integrate quickly

1. Copy the following code and save it as the icon_version.sh script file. Note: Change the icons_path and icons_dest_path paths to the actual icon resource paths or names of your own projects.

#! /bin/sh convertPath=`which convert` echo ${convertPath} if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then echo "warning: Skipping Icon versioning, you need to install ImageMagick and ghostscript (fonts) first, you can use brew to simplify process: brew install imagemagick brew install ghostscript" exit -1; Version = '/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"` build_num=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${CONFIGURATION_BUILD_DIR} / ${INFOPLIST_PATH}" ` # to check the current in the Git branch if [-d. Git] | | Git rev - parse --git-dir > /dev/null 2>&1; then commit=`git rev-parse --short HEAD` branch=`git rev-parse --abbrev-ref HEAD` else commit=`hg identify -i` branch=`hg identify -b` fi; shopt -s extglob build_num="${build_num##*( )}" shopt -u extglob caption="${version}($build_num)\n${branch}\n${commit}" echo $caption function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs -l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" ]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename \"$1\"`"; fi; fi; popd > /dev/null; } function processIcon() { base_file=$1 temp_path=$2 dest_path=$3 if [[ ! -e $base_file ]]; then echo "error: file does not exist: ${base_file}" exit -1; fi if [[ -z $temp_path ]]; then echo "error: temp_path does not exist: ${temp_path}" exit -1; fi if [[ -z $dest_path ]]; then echo "error: dest_path does not exist: ${dest_path}" exit -1; fi file_name=$(basename "$base_file") final_file_path="${dest_path}/${file_name}" base_tmp_normalizedFileName="${file_name%.*}-normalized.${file_name##*.}" base_tmp_normalizedFilePath="${temp_path}/${base_tmp_normalizedFileName}" # Normalize echo "Reverting optimized PNG to normal" echo "xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q '${base_file}' '${base_tmp_normalizedFilePath}'" xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q "${base_file}" "${base_tmp_normalizedFilePath}" width=`identify -format %w "${base_tmp_normalizedFilePath}"` height=`identify -format %h "${base_tmp_normalizedFilePath}"` band_height=$((($height * 50) / 100)) band_position=$(($height - $band_height)) text_position=$(($band_position - 8)) point_size=$(((12 * $width) / 100)) echo "Image dimensions ($width x $height) - band height $band_height @ $band_position - point size $point_size" # # blur band and text # convert "${base_tmp_normalizedFilePath}" -blur 10x8 /tmp/blurred.png convert /tmp/blurred.png -gamma 0 -fill white -draw "rectangle 0,$band_position,$width,$height" /tmp/mask.png convert -size ${width}x${band_height} xc:none -fill 'rgba(0,0,0,0.2)' -draw "rectangle 0,0,$width,$band_height"/TMP/allages-base.png convert-background none-size ${width}x${band_height} -pointsize $point_size -fill white -gravity center -gravity South caption:"$caption" /tmp/labels.png convert "${base_tmp_normalizedFilePath}" /tmp/blurred.png /tmp/mask.png -composite /tmp/temp.png rm /tmp/blurred.png rm /tmp/mask.png # # compose final image # filename=New"${base_file}" convert /tmp/temp.png /tmp/labels-base.png -geometry +0+$band_position -composite /tmp/labels.png -geometry +0+$text_position -geometry +${w}-${h} -composite -alpha remove "${final_file_path}" # clean up rm /tmp/temp.png rm /tmp/labels-base.png rm /tmp/labels.png rm "${base_tmp_normalizedFilePath}" echo "Overlayed ${final_file_path}" } # Process all app icons and create the corresponding internal icons # icons_dir="${SRCROOT}/Images.xcassets/AppIcon.appiconset" icons_path="${PROJECT_DIR}/DaRenShop/Images.xcassets/AppIcon.appiconset" icons_dest_path="${PROJECT_DIR}/DaRenShop/Images.xcassets/AppIcon-Internal.appiconset" icons_set=`basename "${icons_path}"` tmp_path="${TEMP_DIR}/IconVersioning" echo "icons_path: ${icons_path}" echo "icons_dest_path: ${icons_dest_path}" mkdir -p "${tmp_path}" if [[ $icons_dest_path == "\\" ]]; then echo "error: destination file path can't be the root directory" exit -1; fi rm -rf "${icons_dest_path}" cp -rf "${icons_path}" "${icons_dest_path}" # Reference: https://askubuntu.com/a/343753 find "${icons_path}" -type f -name "*.png" -print0 | while IFS= read -r -d '' file; do echo "$file" processIcon "${file}" "${tmp_path}" "${icons_dest_path}" doneCopy the code

2. Place icon_version.sh in the Xcode project directory.

3. Configure the Build Phases TAB in Xcode and select New Run Script Phase to add Run Script.

**4. Fill in shell content”{SRCROOT}/ Actual project file path /icon_version.sh5. Configure the General TAB in Xcode, select the App Icons and Launch Images TAB and change the App Icons Source to Appicon-internal.

6. Run Xcode project to automatically generate a set of App icon resource files named Appicon-internal, which contain overwriting information.

Four,

Xcode9 builds iOS11 App icon, does not show the problem:

Using Xcode9 to build iOS11 system AppIcon, the default read resource file, instead of the Icon Icon of App package, resulting in no display. In this article, by generating independent Appicon-internal resource file:

  • Appicon-internal resource icon files are generated regardless of Release and Debug builds.
  • Regardless of Xcode versions, you need to manually set the official and beta App Icons Source.

Alternatively, generate ICONS in App packages from AppIcon resource files:

  • Appicon-internal resource icon files will not be generated. Only the original App icon will be automatically replaced under Debug.
  • It needs to be built using Xcode8 and does not need to manually set the official and beta App Icons Source.
  • When Xcode9 builds iOS11 system ICONS, they are not displayed.

Develop the version logo

Making address:

https://github.com/MrLujh/AppIconVersion