Skip to content

Instantly share code, notes, and snippets.

@mikesorae
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesorae/e2f30e8341183d72d74e to your computer and use it in GitHub Desktop.
Save mikesorae/e2f30e8341183d72d74e to your computer and use it in GitHub Desktop.
gradle build script for xcode project
//-------------------------------
// load default config file
//-------------------------------
def default_env_conf_url = file("default.gradle").toURL()
def config = new ConfigSlurper().parse(default_env_conf_url)
// load environment config file
if (hasProperty('env')) {
def env_config_url = file("${env}.gradle").toURL()
config = config.merge(new ConfigSlurper().parse(env_config_url))
}
//-------------------------------
// default settings of gradle
//-------------------------------
buildscript {
repositories {
maven {
url('http://openbakery.org/repository/')
}
mavenCentral()
}
dependencies {
classpath group: 'org.openbakery', name: 'xcodePlugin', version: '0.10.+'
}
}
apply plugin: 'xcode'
//-------------------------------
// settings of xcode plugin
//-------------------------------
xcodebuild {
sdk = config.app.sdk
scheme = config.app.scheme
bundleNameSuffix = config.app.bundleNameSuffix
configuration = config.app.configuration
signing {
certificateURI = config.certificate.certificateURI
certificatePassword = config.certificate.certificatePassword
mobileProvisionURI = config.certificate.mobileProvisionURI
identity = config.certificate.identity
}
infoPlist = config.plist.infoPlist
}
infoplist {
bundleDisplayName = config.plist.bundleDisplayName
bundleDisplayNameSuffix = config.plist.bundleDisplayNameSuffix
bundleIdentifier = config.plist.bundleIdentifier
bundleIdentifierSuffix = config.plist.bundleIdentifierSuffix
}
//-------------------------------
// custom tasks
//-------------------------------
task adhoc(dependsOn: ["clean", "infoplistModify", "package"]) << {
description = 'creating ipa file'
}
// adhoc.dependsOn "package"
task release(dependsOn: ["clean", "infoplistModify", "package"]) << {
description = 'creating xcodearchive'
}
gradle.taskGraph.whenReady { taskGraph ->
def revisionHash = ["sh", "-c", "cd ${project.rootDir} ; git rev-parse --short HEAD"].execute().in.text.trim()
if (taskGraph.hasTask(adhoc)) {
println "CONFIGURE Adhoc"
xcodebuild {
// additionalParameters = ["PRODUCT_NAME=${config.plist.bundleDisplayName}_${revisionHash}"]
}
infoplist {
}
}
}
app {
sdk = "iphoneos"
scheme = 'GradleTest'
bundleNameSuffix = "-debug"
configuration = 'Debug'
}
plist {
infoPlist = 'GradleTest/GradleTest-Info.plist'
bundleIdentifier = 'me.247jp.gradle-test'
bundleDisplayName = 'Gradle'
bundleIdentifierSuffix = '.debug'
bundleDisplayNameSuffix = "-db"
}
certificate {
certificateURI = 'http://localhost/release.p12'
certificatePassword = 'xxxxx'
mobileProvisionURI = 'http://localhost/adhoc.mobileprovision'
identity = 'iPhone Distribution: xxxxxx'
}
@mikesorae
Copy link
Author

Usage

gradle adhoc
gradle adhoc -Penv=${env_name}

@mikesorae
Copy link
Author

fixed that xcode plugin does not use specified mobileProvisionURI

@mikesorae
Copy link
Author

adapt to xcode-plugin 0.10+.
now it will fail if bundleDisplaySuffix in default.gradle was set.

pls make it empty for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment