├── LICENSE ├── README.md └── archiveExample.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ruijun Li 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Build Script 2 | script to build iOS app 3 | 4 | Easy to build, package and upload your app. 5 | 6 | ## How to Use 7 | 8 | Copy archiveExample.sh, change config, rename. 9 | 10 | ### Build Configs 11 | 12 | ``` 13 | # path where locate your project 14 | PROJECT_PATH="/Users/apple/Documents/projectpath" 15 | 16 | # workspace name 17 | PROJECT_WORKSPACE="MyProject.xcworkspace" 18 | 19 | # where to find your workspace 20 | PROJECT_WORKSPACE_PATH="$PROJECT_PATH/$PROJECT_WORKSPACE" 21 | 22 | # project file name 23 | PROJECT_FILE_NAME="MyProject.xcodeproj" 24 | 25 | # project file path 26 | PROJECT_FILE_PATH="$PROJECT_PATH/$PROJECT_FILE_NAME" 27 | 28 | # target to build 29 | TARGET_NAME="TargetNameInXcode" 30 | 31 | # scheme name to build 32 | SCHEME_NAME="SchemeNameInXcode" 33 | 34 | # out put app name also prefix for log files 35 | APP_NAME="IPA file name" 36 | 37 | # configuration name Release or Debug 38 | CONFIGURATION_NAME="Release" 39 | 40 | # tool for modify plist file 41 | PB="/usr/libexec/PlistBuddy" 42 | 43 | # time stamp for current build 44 | TIMESTEMP=`date +%Y%m%d%H%M%S` 45 | 46 | # use timestamp for build path you can change later 47 | BUILD_DIR="archives/$APP_NAME$TIMESTEMP" 48 | # you can change BUILD_PATH to your own path for testing script 49 | #BUILD_DIR="archives/MyApp20151029010836" 50 | 51 | # if you want update cocoapods 52 | UPDATE_POD=false 53 | ``` 54 | 55 | After you have finished your config, just using `buildPackage` to build binary. 56 | 57 | ### Package IPA 58 | 59 | ``` 60 | # package with same output you can call packageApp many times 61 | 62 | # package first package 63 | # profile file name 64 | PROFILE_NAME="profilename.mobileprovision" 65 | 66 | # profile path 67 | PROFILE_PATH=$SCRIPT_BASE/$PROFILE_NAME 68 | 69 | # developer name use user id eg. 70 | # DEVELOPER_NAME="CCF342CZ34" 71 | DEVELOPER_NAME="" 72 | 73 | # ipa name 74 | TARGET_IPA_NAME=$APP_NAME 75 | ``` 76 | 77 | After you have finished your config, just using `packageApp` to build binary. 78 | 79 | Get final out put path using `FILEPATH1=$BUILD_PATH/$TARGET_IPA_NAME.ipa`. 80 | 81 | You can change package config and package app many times with different developer sign and provision profile. 82 | 83 | ### Upload to pgyer.com 84 | 85 | Call `uploadPgyer` to upload app to pgyer.com like this: 86 | 87 | ``` 88 | uploadPgyer $FILEPATH1 "password" "_api_key" "uKey">$LOG_PATH/$APP_NAME.upload.log 89 | ``` 90 | 91 | - `password` is password using to download your app at Pgyer.com 92 | - `_api_key` is api key that provided by Pgyer.com 93 | - `uKey` is uKey that provided by Pgyer.com 94 | 95 | ### Logs and DSYMs 96 | 97 | You can find logs in `$LOG_PATH`, DYSM files in `$DSYM_PATH`. 98 | 99 | Have fun. 100 | 101 | ## Todo: 102 | 103 | - Support uploading to fir.im 104 | -------------------------------------------------------------------------------- /archiveExample.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use current path for build 4 | SCRIPT_BASE=`pwd` 5 | 6 | # path where locate your project 7 | PROJECT_PATH="/Users/apple/Documents/projectpath" 8 | 9 | # workspace name 10 | PROJECT_WORKSPACE="MyProject.xcworkspace" 11 | 12 | # where to find your workspace 13 | PROJECT_WORKSPACE_PATH="$PROJECT_PATH/$PROJECT_WORKSPACE" 14 | 15 | # project file name 16 | PROJECT_FILE_NAME="MyProject.xcodeproj" 17 | 18 | # project file path 19 | PROJECT_FILE_PATH="$PROJECT_PATH/$PROJECT_FILE_NAME" 20 | 21 | # target to build 22 | TARGET_NAME="TargetNameInXcode" 23 | 24 | # scheme name to build 25 | SCHEME_NAME="SchemeNameInXcode" 26 | 27 | # out put app name also prefix for log files 28 | APP_NAME="IPA file name" 29 | 30 | # configuration name Release or Debug 31 | CONFIGURATION_NAME="Release" 32 | 33 | # tool for modify plist file 34 | PB="/usr/libexec/PlistBuddy" 35 | 36 | # time stamp for current build 37 | TIMESTEMP=`date +%Y%m%d%H%M%S` 38 | 39 | # use timestamp for build path you can change later 40 | BUILD_DIR="archives/$APP_NAME$TIMESTEMP" 41 | # you can change BUILD_PATH to your own path 42 | #BUILD_DIR="archives/MyApp20151029010836" 43 | 44 | cd .. 45 | if [ ! -d $BUILD_DIR ]; then 46 | mkdir -p $BUILD_DIR 47 | fi 48 | cd $BUILD_DIR 49 | BUILD_PATH=`pwd` 50 | LOG_PATH=$BUILD_PATH/log 51 | if [ ! -d $LOG_PATH ]; then 52 | mkdir -p $LOG_PATH 53 | fi 54 | DSYM_PATH=$BUILD_PATH/dsyms 55 | if [ ! -d $DSYM_PATH ]; then 56 | mkdir -p $DSYM_PATH 57 | fi 58 | 59 | # build target path 60 | TARGET_PATH=$BUILD_PATH/$TARGET_NAME 61 | 62 | # if you want update cocoapods 63 | UPDATE_POD=false 64 | 65 | # import build script 66 | . $SCRIPT_BASE/buildAndArchive.sh 67 | 68 | echo "\033[33mInfo: Start $APP_NAME Build\033[0m" 69 | declare -i ret 70 | ret=0 71 | # build package 72 | buildPackage 73 | ret=$? 74 | 75 | # package with same output you can call packageApp many times 76 | 77 | # package first package 78 | # profile file name 79 | PROFILE_NAME="profilename.mobileprovision" 80 | 81 | # profile path 82 | PROFILE_PATH=$SCRIPT_BASE/$PROFILE_NAME 83 | 84 | # developer name use user id eg. 85 | # DEVELOPER_NAME="CCF342CZ34" 86 | DEVELOPER_NAME="" 87 | 88 | # ipa name 89 | TARGET_IPA_NAME=$APP_NAME 90 | 91 | # package app 92 | if [ $ret -eq 0 ]; then 93 | packageApp 94 | ret=$? 95 | fi 96 | 97 | FILEPATH1=$BUILD_PATH/$TARGET_IPA_NAME.ipa 98 | 99 | # package second package you can change provisioning profile and sign user 100 | # profile file name 101 | PROFILE_NAME="profilename.mobileprovision" 102 | 103 | # profile path 104 | PROFILE_PATH=$SCRIPT_BASE/$PROFILE_NAME 105 | 106 | # developer name use user id eg. 107 | # DEVELOPER_NAME="CCF342CZ34" 108 | DEVELOPER_NAME="" 109 | 110 | # ipa name 111 | TARGET_IPA_NAME=$APP_NAME.copy 112 | 113 | # package app 114 | if [ $ret -eq 0 ]; then 115 | packageApp 116 | ret=$? 117 | fi 118 | 119 | FILEPATH2=$BUILD_PATH/$TARGET_IPA_NAME.ipa 120 | 121 | open $BUILD_PATH 122 | 123 | echo 124 | echo "\033[32mBuild script path: $SCRIPT_BASE\033[0m" 125 | echo "\033[32mLogging path: $LOG_PATH\033[0m" 126 | echo "\033[32mDSYM file path: $DSYM_PATH\033[0m" 127 | echo 128 | 129 | if [ $ret -eq 0 ]; then 130 | echo "All has been done!!! Have fun!!!🍻 " 131 | else 132 | echo "\033[91m😱 😱 😱 Build Failed!!!!!!\033[0m" 133 | fi 134 | echo 135 | 136 | # upload every package to pyger.com for Ad-hoc user install 137 | echo "\033[33mInfo: Uploading $FILEPATH1\033[0m" 138 | uploadPgyer $FILEPATH1 "password" "_api_key" "uKey">$LOG_PATH/$APP_NAME.upload.log 139 | if [[ $? -ne 0 ]]; then 140 | echo "\033[91mUpload $FILEPATH1 failed try it later" 141 | fi 142 | echo "\033[33mInfo: Uploading $FILEPATH2\033[0m" 143 | uploadPgyer $FILEPATH2 "password" "_api_key" "uKey">$LOG_PATH/$APP_NAME.copy.upload.log 144 | if [[ $? -ne 0 ]]; then 145 | echo "\033[91mUpload $FILEPATH2 failed try it later" 146 | fi 147 | 148 | echo "\033[33mInfo: Upload finished!\033[0m" 149 | --------------------------------------------------------------------------------