-
-
Save mitchellporter/f80e7a6d23b35dcc9800a4f7f93d9d33 to your computer and use it in GitHub Desktop.
Revisions
-
acrookston revised this gist
May 4, 2016 . 1 changed file with 4 additions and 4 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 @@ -7,7 +7,7 @@ Installation procedure for pre-build actions to automatically populate Xcode Inf Edit Xcode Scheme and add a pre-action script. Copy the contents of `preaction.sh` into the pre-action script box.  ### 2. Copy processing file @@ -22,7 +22,7 @@ Copy the contents of `preaction.sh` into the pre-action script box. 2. For each Target Build Settings set `Preprocess Info.plist file` to YES. 3. Enter `environment_preprocess.h` (or the output file if you renamed it `build_environment.sh`) into `Info.plist Preprocessor Prefix File`  ### 4. Install plist file @@ -31,7 +31,7 @@ Copy `development.plist` file to `config/environments/development.plist`. DO NOT If you have several schemes setup in the previous step (`ENVIORMENT`) you need to copy this file to each option if you use multiple build schemes and `ENVIRONMENT` variables.  ### 5. Setup environment variables @@ -50,7 +50,7 @@ TIP 2: You can use it to use git commit count as the build version/number. 6. Use those generated environment variables in your `Info.plist`.  ### 7. Run Build! -
acrookston revised this gist
May 4, 2016 . 2 changed files with 5 additions and 5 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 @@ -7,7 +7,7 @@ Installation procedure for pre-build actions to automatically populate Xcode Inf Edit Xcode Scheme and add a pre-action script. Copy the contents of `preaction.sh` into the pre-action script box.  ### 2. Copy processing file @@ -22,7 +22,7 @@ Copy the contents of `preaction.sh` into the pre-action script box. 2. For each Target Build Settings set `Preprocess Info.plist file` to YES. 3. Enter `environment_preprocess.h` (or the output file if you renamed it `build_environment.sh`) into `Info.plist Preprocessor Prefix File`  ### 4. Install plist file @@ -31,7 +31,7 @@ Copy `development.plist` file to `config/environments/development.plist`. DO NOT If you have several schemes setup in the previous step (`ENVIORMENT`) you need to copy this file to each option if you use multiple build schemes and `ENVIRONMENT` variables.  ### 5. Setup environment variables @@ -50,9 +50,9 @@ TIP 2: You can use it to use git commit count as the build version/number. 6. Use those generated environment variables in your `Info.plist`.  ### 7. Run Build! This will generate the `environment_preprocess.h` file and make it available for inclusion in your `Info.plist` It's advisable to exclude the generated file from any version control system. LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
acrookston revised this gist
May 4, 2016 . 1 changed file with 54 additions and 7 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 @@ -2,10 +2,57 @@ Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data. ### 1. Xcode Scheme pre-action Edit Xcode Scheme and add a pre-action script. Copy the contents of `preaction.sh` into the pre-action script box.  ### 2. Copy processing file 1. Copy `build_environment.sh` to `config/environments/build_environment.sh`. 2. Modify it's variables or path to `environment_preprocess.h` as needed. ### 3. Edit Xcode Build Settings 1. For the `Project Build Settings` add a new User-Defined variables called `ENVIRONMENT`, for each scheme set the appropriate name eg `development` or `production`. 2. For each Target Build Settings set `Preprocess Info.plist file` to YES. 3. Enter `environment_preprocess.h` (or the output file if you renamed it `build_environment.sh`) into `Info.plist Preprocessor Prefix File`  ### 4. Install plist file Copy `development.plist` file to `config/environments/development.plist`. DO NOT include this file in any Target Memberships. If you have several schemes setup in the previous step (`ENVIORMENT`) you need to copy this file to each option if you use multiple build schemes and `ENVIRONMENT` variables.  ### 5. Setup environment variables This file `development.plist` (and others) is used to populate data in the `build_environment.sh` script. Modify contents as needed and don't forget to also modify the `build_environment.sh` accordingly. This is really where the magic happens. The rest is just for running this script and processing the output. TIP 1: You can run pretty much anything in the `environment_preprocess.h` script if you want to setup link to a local development server you can use the `hostname` command to get your current build computer's network name. TIP 2: You can use it to use git commit count as the build version/number. (Both of these are included in the script already.) ### 6. Using environment variables 6. Use those generated environment variables in your `Info.plist`.  ### 7. Run Build! This will generate the `environment_preprocess.h` file and make it available for inclusion in your `Info.plist` It's advisable to exclude the generated file from any version control system. -
acrookston revised this gist
Apr 13, 2016 . 1 changed file with 1 addition and 1 deletion.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,4 +1,4 @@ ## Automatic build versions from git in Xcode (and other goodies) Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data. -
acrookston revised this gist
Apr 13, 2016 . 1 changed file with 1 addition and 1 deletion.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,4 +1,4 @@ # Automatic build versions from git in Xcode (and other goodies) Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data. -
acrookston revised this gist
Apr 13, 2016 . 1 changed file with 4 additions and 4 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 @@ -4,8 +4,8 @@ Installation procedure for pre-build actions to automatically populate Xcode Inf 1. Edit Xcode Scheme and add a pre-action script (see xcode-manage-preaction.png). Copy the included script into the pre-build box. 2. Edit Xcode Build Settings to use Info.plist preprocessing and enter the script header file name in Prefix File. 3. Copy the `development.plist` file to `config/environments/development.plist` (or wherever but don't forget to change the paths). 4. Copy `build_environment.sh` to `config/environments/build_environment.sh` 5. Update the `build_environment.sh` script to output whatever environment variables you need. Note it reads defaults from the `development.plist`. 6. Use those environment variables in your `Info.plist`. See example image for usage (eg. `ENV_APP_NAME`). 7. Build! -
acrookston revised this gist
Apr 13, 2016 . 1 changed file with 2 additions and 1 deletion.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 @@ -7,4 +7,5 @@ Installation procedure for pre-build actions to automatically populate Xcode Inf 3. Copy the development.plist file to config/environments/development.plist (or wherever but don't forget to change the path). 4. Copy build_environment.sh to config/environments/build_environment.sh 5. Update the build_environment.sh script to output whatever environment variables you need. 6. Use those environment variables in your Info.plist. See example image for usage (eg. ENV_APP_NAME). 7. Build! -
acrookston revised this gist
Apr 13, 2016 . 2 changed files with 11 additions and 1 deletion.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,10 @@ # Automatic build versions in Xcode (and other goodies) Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data. 1. Edit Xcode Scheme and add a pre-action script (see xcode-manage-preaction.png). Copy the included script into the pre-build box. 2. Edit Xcode Build Settings to use Info.plist preprocessing and enter the script header file name in Prefix File. 3. Copy the development.plist file to config/environments/development.plist (or wherever but don't forget to change the path). 4. Copy build_environment.sh to config/environments/build_environment.sh 5. Update the build_environment.sh script to output whatever environment variables you need. 6. Use those environment variables in your Info.plist. See example image for usage (eg. ENV_APP_NAME). 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,4 +1,4 @@ #!/bin/sh cd $PROJECT_DIR exec > $PROJECT_DIR/pre_action.log 2>&1 source $PROJECT_DIR/config/environments/build_environment.sh -
acrookston revised this gist
Apr 13, 2016 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
acrookston revised this gist
Apr 13, 2016 . No changes.There are no files selected for viewing
-
acrookston revised this gist
Apr 13, 2016 . 1 changed file with 18 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 @@ -0,0 +1,18 @@ <?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>README</key> <string>Copy this file to config/environments/development.plist. DO NOT add it to the targets! It gets copied to environment.plist during build. See build_environment script for more.</string> <key>AppGroup</key> <string>your.app.group</string> <key>HostName</key> <string>localhost</string> <key>AppName</key> <string>Your app name</string> <key>CFBundleShortVersionString</key> <string>1.1</string> <key>RandomKey</key> <string>whatever you want</string> </dict> </plist> -
acrookston created this gist
Apr 13, 2016 .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,81 @@ #!/bin/sh # build_environment.sh # # Created by Andrew C on 7/27/15. # Released under MIT LICENSE # Copyright (c) 2015 Andrew Crookston. cd "${PROJECT_DIR}" dir=${PROJECT_DIR}/config/environments echo "Starting environment ${ENVIRONMENT} configuration for ${PROJECT_NAME}/${PROJECT_FOLDER} with config in " $dir echo "Host: " `hostname` # environment variable from value passed in to xcodebuild. # if not specified, we default to DEV env=${ENVIRONMENT} if [ -z "$env" ] then env="development" fi echo "Using $env environment" # copy the environment-specific file cp $dir/$env.plist $dir/environment.plist # Date and time that we are running this build buildDate=`date "+%F %H:%M:%S"` todaysDay=`date "+%d"` # app settings appName=`/usr/libexec/PlistBuddy -c "Print :AppName" "$dir/environment.plist"` appGroup=`/usr/libexec/PlistBuddy -c "Print :AppGroup" "$dir/environment.plist"` version=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$dir/environment.plist"` hostname=`/usr/libexec/PlistBuddy -c "Print :HostName" "$dir/environment.plist"` hostscheme=`/usr/libexec/PlistBuddy -c "Print :HostScheme" "$dir/environment.plist"` bundle=`git rev-list master |wc -l | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'` if [ "$env" == "development" ] then hostname=`hostname` # need to dynamically append today's day for non-prod appName="$appName-$todaysDay" # Last hash from the current branch #version=`git log --pretty=format:"%h" -1` fi buildhost=`hostname` # Build the preprocess file cd "${PROJECT_DIR}" preprocessFile="environment_preprocess.h" echo "Creating header file ${PROJECT_DIR}/${preprocessFile}" echo "//------------------------------------------" > $preprocessFile echo "// Auto generated file. Don't edit manually." >> $preprocessFile echo "// See build_environment script for details." >> $preprocessFile echo "// Created $buildDate" >> $preprocessFile echo "//------------------------------------------" >> $preprocessFile echo "" >> $preprocessFile echo "#define ENV $env" >> $preprocessFile echo "#define ENV_APP_NAME $appName" >> $preprocessFile echo "#define ENV_APP_GROUP $appGroup" >> $preprocessFile echo "#define ENV_APP_VERSION $version" >> $preprocessFile echo "#define ENV_HOST_NAME $hostname" >> $preprocessFile echo "#define ENV_BUILD_HOST $buildhost" >> $preprocessFile echo "#define ENV_BUNDLE_VERSION $bundle" >> $preprocessFile echo "#define ENV_HOST_SCHEME $hostscheme" >> $preprocessFile # dump out file to build log cat $preprocessFile # Force the system to process the plist file echo "Touching all plists at: ${PROJECT_DIR}/**/Info.plist" touch ${PROJECT_DIR}/**/Info.plist # done echo "Done." 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,4 @@ #!/bin/sh cd $PROJECT_DIR exec > $PROJECT_DIR/pre_action.log 2>&1 source $PROJECT_DIR/build_environment.sh