Forked from CodeEagle/Xcode Team Adding Build Number Shell Script
Last active
September 22, 2015 01:22
-
-
Save xrksudy/7f9b5dc7427b02aef3da to your computer and use it in GitHub Desktop.
Revisions
-
CodeEagle revised this gist
Sep 15, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,10 @@ # 1. Select: your Target in Xcode # 2. Select: Build Phases Tab # 3. Select: Add Build Phase -> Add Run Script # 4. Paste code below in to new "Run Script" section # 5. Drag the "Run Script" below "Link Binaries With Libraries" # 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0) currentUser="$USER" cretePlist() { -
CodeEagle renamed this gist
Sep 15, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
CodeEagle created this gist
Sep 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ currentUser="$USER" cretePlist() { cat > build.plist <<EOF <?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>$currentUser</key> <string>1</string> <key>users</key> <string>$currentUser</string> </dict> </plist> EOF } [ -f ${PROJECT_DIR}/build.plist ] && echo "Found build.plist" || cretePlist users=$(/usr/libexec/PlistBuddy -c "Print users" "${PROJECT_DIR}/build.plist") mybuild=$(/usr/libexec/PlistBuddy -c "Print $currentUser" "${PROJECT_DIR}/build.plist") alreadyIn=0 if [[ $users == *"$currentUser"* ]] then alreadyIn=1 fi if [ ${alreadyIn} -eq 0 ]; then users="$users|$currentUser" build=1 /usr/libexec/PlistBuddy -c "Set :users $users" "${PROJECT_DIR}/build.plist" /usr/libexec/PlistBuddy -c "Add :$currentUser string $build" "${PROJECT_DIR}/build.plist" else mybuild=$(($mybuild + 1)) /usr/libexec/PlistBuddy -c "Set :$currentUser $mybuild" "${PROJECT_DIR}/build.plist" fi IFS='|' read -ra ADDR <<< "$users" totalBuild=0 for i in "${ADDR[@]}"; do echo "$i" memberbuild=$(/usr/libexec/PlistBuddy -c "Print $i" "${PROJECT_DIR}/build.plist") totalBuild=$(($totalBuild + $memberbuild)) done echo $totalBuild /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $totalBuild" "${PROJECT_DIR}/${INFOPLIST_FILE}"