Skip to content

Commit

Permalink
Improve ArchiveTask provide optional team id (#56)
Browse files Browse the repository at this point in the history
Description
===========

During archive and the resulting code sign, it can happen that Xcode has
issues with ambigious certificate names. It is possible to provide a
`DEVELOPMENT_TEAM` flag during invocation and providing the teamId for
code sign.

This patch adds a new optional task input variable `teamId` to the
`Archive` task and sets the `DEVELOPMENT_TEAM` option during execution
if the property is set. The plugin will provide a default value from the
plugin extension.

Changes
=======

* ![IMPROVE] ![IOS] `ArchiveTask` provide optional team id
  • Loading branch information
Larusso authored May 19, 2020
1 parent babe0da commit fb318d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class IOSBuildPlugin implements Plugin<Project> {
conventionMapping.map("extension", { "xcarchive" })
conventionMapping.map("scheme", { extension.getScheme() })
conventionMapping.map("configuration", { extension.getConfiguration() })
conventionMapping.map("teamId", { extension.getTeamId() })
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import org.gradle.api.tasks.*
import org.gradle.util.GUtil
import wooga.gradle.build.unity.ios.XCAction

import java.util.concurrent.Callable

class XCodeArchiveTask extends ConventionTask {

private Object projectPath
Expand Down Expand Up @@ -152,6 +154,23 @@ class XCodeArchiveTask extends ConventionTask {
this
}

private Object teamId

@Optional
@Input
String getTeamId() {
convertToString(teamId)
}

void setTeamId(Object value) {
teamId = value
}

ImportProvisioningProfile teamId(Object teamId) {
setTeamId(teamId)
this
}

@Internal("Represented as part of archivePath")
String getArchiveName() {
if (customName != null) {
Expand Down Expand Up @@ -299,6 +318,10 @@ class XCodeArchiveTask extends ConventionTask {
arguments << "OTHER_CODE_SIGN_FLAGS=--keychain ${getBuildKeychain()}"
}

if (getTeamId()) {
arguments << "DEVELOPMENT_TEAM=${getTeamId()}"
}

arguments << "-archivePath" << getArchivePath().getPath()

def derivedDataPath = new File(project.buildDir, "derivedData")
Expand All @@ -311,4 +334,16 @@ class XCodeArchiveTask extends ConventionTask {
args = arguments
}
}
}

private static String convertToString(Object value) {
if (!value) {
return null
}

if (value instanceof Callable) {
value = ((Callable) value).call()
}

value.toString()
}
}

0 comments on commit fb318d3

Please sign in to comment.