├── Makefile ├── Makefile.cfg └── README.md /Makefile: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # Copyright © 2013 Carl Chen. 3 | 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the “Software”), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | 14 | # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | 23 | include Makefile.cfg 24 | 25 | ProjectAbsolutePath = $(shell pwd) 26 | 27 | WorkFolder = build 28 | 29 | VPATH = $(WorkFolder) 30 | 31 | WorkPath = $(ProjectAbsolutePath)/$(WorkFolder) 32 | 33 | CompileOutputPath = $(WorkPath)/iPhoneOS 34 | 35 | UploadPath = $(WorkPath)/upload 36 | 37 | PlistBuddyPath = /usr/libexec/PlistBuddy 38 | 39 | Configuration ?= Release 40 | 41 | #define InfoPlistFilePath 42 | #$(shell echo $(CompileOutputPath)/*.app/Info.plist) 43 | #endef 44 | 45 | InfoClr = \033[01;33m 46 | ResultClr = \033[01;32m 47 | ResetClr = \033[0m 48 | 49 | BuildCmdConfig = -configuration $(Configuration) CONFIGURATION_BUILD_DIR=$(CompileOutputPath) 50 | 51 | ifneq ($(Scheme),) 52 | BuildCmdConfig += -scheme $(Scheme) 53 | endif 54 | 55 | ifneq ($(ProvisioningProfile),) 56 | BuildCmdConfig += PROVISIONING_PROFILE=$(ProvisioningProfile) 57 | endif 58 | 59 | 60 | define AppDisplayName 61 | $(shell $(PlistBuddyPath) -c 'print CFBundleDisplayName' $(CompileOutputPath)/*.app/Info.plist) 62 | endef 63 | 64 | define AppBuildVersion 65 | $(shell $(PlistBuddyPath) -c 'print CFBundleVersion' $(CompileOutputPath)/*.app/Info.plist) 66 | endef 67 | 68 | define AppBuildIdentifier 69 | $(shell $(PlistBuddyPath) -c 'print CFBundleIdentifier' $(CompileOutputPath)/*.app/Info.plist) 70 | endef 71 | 72 | define AppBundleName 73 | $(shell $(PlistBuddyPath) -c 'print CFBundleName' $(CompileOutputPath)/*.app/Info.plist) 74 | endef 75 | 76 | UploadPlistName = $(AppBundleName).plist 77 | 78 | UploadLogoName = logo.png 79 | 80 | UploadPlistPath = $(UploadPath)/$(UploadPlistName) 81 | 82 | ItemsURL = itms-services://?action=download-manifest&url=$(PlistFileHttpsURL) 83 | 84 | AppName ?= $(AppDisplayName) 85 | 86 | GitLog = $(shell git log --no-merges --pretty=format:"\r✓ %s" --abbrev-commit --date=relative -n 10 | /usr/bin/php -r 'echo htmlentities(fread( STDIN, 2048 ), ENT_QUOTES, "UTF-8");') 87 | 88 | define html 89 | '\ 90 | $(AppName)\ 97 |
\ 98 |

\ 99 |

$(AppName)


\ 100 | Built on '`date "+%Y-%m-%d %H:%M:%S"`'\ 101 |
INSTALL


\ 102 |
$(GitLog)
......
\ 103 | \ 104 | ' 105 | endef 106 | 107 | 108 | all : package uploadFiles 109 | .PHONY : all compile package uploadFiles plist sendEmail sendIMsg upload 110 | 111 | compile : 112 | @echo "Start building project." 113 | @xcodebuild $(BuildCmdConfig) 114 | 115 | package : compile 116 | @echo "Start packaging." 117 | @xcrun -sdk iphoneos PackageApplication -v $(CompileOutputPath)/*.app -o $(WorkPath)/$(AppBundleName).ipa 118 | 119 | uploadFiles : plist 120 | @cp $(WorkPath)/*.ipa $(UploadPath)/$(AppBundleName).ipa 121 | @-cp Icon@2x.png $(UploadPath)/$(UploadLogoName) 122 | @echo $(html) > $(UploadPath)/index.html 123 | 124 | 125 | plist : 126 | @rm -rf $(UploadPath) 127 | @mkdir $(UploadPath) 128 | @$(PlistBuddyPath) -c "Add :items array" $(UploadPlistPath) $2>/dev/null 129 | @$(PlistBuddyPath) -c "Add :items:0 dict" $(UploadPlistPath) 130 | @$(PlistBuddyPath) -c "Add :items:0:assets array" $(UploadPlistPath) 131 | @$(PlistBuddyPath) -c "Add :items:0:assets:0 dict" $(UploadPlistPath) 132 | @$(PlistBuddyPath) -c "Add :items:0:assets:0:url string \"$(BaseURL)/$(AppBundleName).ipa\"" $(UploadPlistPath) 133 | @$(PlistBuddyPath) -c "Add :items:0:assets:0:kind string software-package" $(UploadPlistPath) 134 | @$(PlistBuddyPath) -c "Add :items:0:assets:1 dict" $(UploadPlistPath) 135 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:kind string display-image" $(UploadPlistPath) 136 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:needs-shine bool NO" $(UploadPlistPath) 137 | @$(PlistBuddyPath) -c "Add :items:0:assets:1:url string \"$(BaseURL)/$(UploadLogoName)\"" $(UploadPlistPath) 138 | @$(PlistBuddyPath) -c "Add :items:0:assets:2 dict" $(UploadPlistPath) 139 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:kind string full-size-image" $(UploadPlistPath) 140 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:needs-shine bool NO" $(UploadPlistPath) 141 | @$(PlistBuddyPath) -c "Add :items:0:assets:2:url string \"$(BaseURL)/$(UploadLogoName)\"" $(UploadPlistPath) 142 | @$(PlistBuddyPath) -c "Add :items:0:metadata dict" $(UploadPlistPath) 143 | @$(PlistBuddyPath) -c "Add :items:0:metadata:title string \"$(AppName)\"" $(UploadPlistPath) 144 | @$(PlistBuddyPath) -c "Add :items:0:metadata:kind string software" $(UploadPlistPath) 145 | @$(PlistBuddyPath) -c "Add :items:0:metadata:bundle-version string \"$(AppBuildVersion)\"" $(UploadPlistPath) 146 | @$(PlistBuddyPath) -c "Add :items:0:metadata:bundle-identifier string \"$(AppBuildIdentifier)\"" $(UploadPlistPath) 147 | @mv $(UploadPlistPath) $(WorkPath) 148 | 149 | sendEmail : 150 | @echo "Sending E-mails..." 151 | @curl -s --user api:$(MailGunApiKey) \ 152 | https://api.mailgun.net/v2/$(MailGunDomain)/messages \ 153 | -F from='$(AppName) ' \ 154 | -F to=$(MailGunReceiveList)\ 155 | -F subject="$(AppName) has been updated" \ 156 | -F text='This email is send by automatical shell created by ccf.Do not reply it directly.' \ 157 | -F "html=<$(UploadPath)/index.html" 158 | @echo "\nMails sent." 159 | 160 | sendIMsg : 161 | @for address in $(IMsgList) ; do \ 162 | echo "Sending iMessage to $${address}..." ; \ 163 | osascript -e "set toAddress to \"$${address}\"" \ 164 | -e "tell application \"Messages\"" \ 165 | -e "set theBuddy to buddy toAddress of (first service whose service type is iMessage)" \ 166 | -e "send \"$(AppName) has been updated. Click to install: $(BaseURL)/index.html\" to theBuddy" \ 167 | -e "end tell" ; \ 168 | done 169 | 170 | upload : 171 | @echo "Uploading...." 172 | 173 | ifneq ($(ScpHost),) 174 | ifneq ($(ScpUser),) 175 | ifneq ($(ScpFilePath),) 176 | @scp $(UploadPath)/* $(ScpUser)@$(ScpHost):$(ScpFilePath) 177 | endif 178 | endif 179 | endif 180 | 181 | ifneq ($(FtpHost),) 182 | ifneq ($(FtpUser),) 183 | ifneq ($(FtpPassword),) 184 | @cd $(UploadPath); ls -l | awk '/^-/{print $$NF}' | while read filename; do curl -u $(FtpUser):$(FtpPassword) -T $${filename} ftp://$(FtpHost)/$${filename}; done 185 | endif 186 | endif 187 | endif 188 | 189 | @echo "Upload success." 190 | 191 | .PHONY : clean 192 | clean : 193 | @xcodebuild clean $(BuildCmdConfig) 194 | @rm -rf $(WorkPath) 195 | -------------------------------------------------------------------------------- /Makefile.cfg: -------------------------------------------------------------------------------- 1 | #------Compile setting-------start 2 | #The configuration of project.(default is Release) 3 | #Configuration = Debug 4 | 5 | #Name of app.(default value is CFBundleDisplayName of Info.plist) 6 | #AppName = 7 | 8 | #Scheme 9 | #Scheme = 10 | 11 | #Provisioning profile 12 | #ProvisioningProfile = 13 | #------Compile setting-------end 14 | 15 | 16 | 17 | #------Http setting------start 18 | BaseURL = http://xxxx.com 19 | 20 | PlistFileHttpsURL = https://xxx.com/xx.plist 21 | #------Http setting------end 22 | 23 | 24 | 25 | #------MailGun setting------start 26 | #use MailGun to send emails. (http://www.mailgun.com/) 27 | MailGunDomain = xxxx.mailgun.org 28 | MailGunReceiveList = xxxx@xxxx.mailgun.org 29 | MailGunApiKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxx 30 | #------MailGun setting------end 31 | 32 | 33 | 34 | #------iMessage setting------start 35 | #Receiver address list(seperated with white space) 36 | IMsgList = 37 | #------iMessage setting------end 38 | 39 | 40 | 41 | #------scp setting------start 42 | #ScpHost = 43 | #ScpUser = 44 | #ScpFilePath = / 45 | #------scp setting------end 46 | 47 | 48 | 49 | #------ftp setting------start 50 | FtpHost = 51 | FtpUser = 52 | FtpPassword = 53 | #------ftp setting------end 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CCMakefile4iOS 2 | ============== 3 | 4 | This project can help you to distribute your iOS project automatically by the terminal. 5 | 6 | ![image](http://webfrogs.me/CCRes/images/2013-10-26_make.gif) 7 | 8 | ##Usage 9 | 10 | Copy the ```Makefile``` and ```Makefile.cfg``` files to the root path of your iOS project(the same directory with the *.xcodeproj* file). 11 | 12 | Open the ```Makefile.cfg``` file and edit it. Then, you can use the ```make``` command as shown below. 13 | 14 | * ```make``` --- compile and package 15 | * ```make upload``` --- upload itms-services files 16 | * ```make sendEmail``` --- send E-mails notification 17 | * ```make sendIMsg``` --- send iMessage notification 18 | 19 | 20 | Tip: Use the ```&&``` to combine and run command in sequence. For example: 21 | 22 | ```make && make upload && make sendEmail```. 23 | 24 | You can do this as you need. 25 | 26 | 27 | 28 | 29 | 30 | ## License 31 | This code is distributed under the terms and conditions of the MIT license. --------------------------------------------------------------------------------