1+ /**
2+ * remember to comment on: http://stackoverflow.com/questions/4991768/build-tool-for-ios-and-mac-projects
3+ * also check: https://github.com/jvoegele/gradle-android-plugin
4+ *
5+ */
6+
7+ description = ' Gradle build for iOS'
8+ defaultTasks = [' tasks' ]
9+ ios = ' iOS'
10+
11+ PROJECT_NAME = ' iBuild'
12+
13+ BUILD_DIR = ' build'
14+ CONFIGURATION = ' Release' // 'Release' or 'Debug'
15+ SDK_TARGET_NAME = ' iphonesimulator' // 'iphonesimulator' or 'iphoneos'
16+ DEFAULT_APP_VERSION = ' 0.0.1'
17+
18+ task clean (type : Delete ) {
19+ group = ios
20+ description = ' Cleanup the project of whatever the build process has created leaving it spic and span.'
21+ delete " ${ SDK_TARGET_NAME} "
22+ doLast {
23+ exec {
24+ executable = ' xcodebuild'
25+ args = [' -alltargets' , ' clean' ]
26+ }
27+ }
28+ }
29+
30+ task compile {
31+ group = ios
32+ description = ' Compilation of sources'
33+ doLast {
34+ exec {
35+ executable = ' xcodebuild'
36+ args = [' -sdk' , " ${ SDK_TARGET_NAME} " , ' -configuration' , " ${ CONFIGURATION} " ]
37+ }
38+ }
39+ }
40+
41+ task(' package' , dependsOn : compile) {
42+ group = ios
43+ description = ' Take the compiled code and package it in a distributable format: eg: app.zip'
44+
45+ def destfile = " ${ PROJECT_NAME} -${ DEFAULT_APP_VERSION} -${ CONFIGURATION} .zip"
46+
47+ doLast {
48+
49+ def wd = " ${ BUILD_DIR} /${ CONFIGURATION} -${ SDK_TARGET_NAME} /"
50+
51+ exec {
52+ executable = ' zip'
53+ workingDir = " ${ wd} "
54+ args = [" -yrq" , " ${ destfile} " , " ${ PROJECT_NAME} .app" , " ${ PROJECT_NAME} .app.dSYM" ]
55+ }
56+
57+ zipFile = " ${ wd} /${ destfile} "
58+
59+ copy {
60+ from zipFile
61+ into ' .'
62+ }
63+
64+ delete zipFile
65+ }
66+ }
67+
68+
69+ task hello {
70+ doLast {
71+ println ' Hello world!'
72+ }
73+ }
0 commit comments