Skip to content

Commit 06ffaf6

Browse files
authored
fix(plugin): check exit value when executing xcodebuild command (#326)
* add error logging * update CHANGELOG
1 parent 4132cdd commit 06ffaf6

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- [Gradle Plugin]: Architecture folder name missmatch when using SPM and framework path searching ([#320](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/320))
8+
- [Gradle Plugin]: Check exit value when executing `xcodebuild` command ([#326](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/326))
89

910
### Dependencies
1011

sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/DerivedDataPathValueSource.kt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.kotlin.multiplatform.gradle
22

3+
import io.sentry.kotlin.multiplatform.gradle.SentryPlugin.Companion.logger
34
import org.gradle.api.provider.Property
45
import org.gradle.api.provider.ValueSource
56
import org.gradle.api.provider.ValueSourceParameters
@@ -29,21 +30,36 @@ abstract class DerivedDataPathValueSource :
2930

3031
override fun obtain(): String? {
3132
val buildDirOutput = ByteArrayOutputStream()
32-
execOperations.exec {
33+
val errOutput = ByteArrayOutputStream()
34+
35+
val execOperations = execOperations.exec {
3336
it.commandLine = listOf(
3437
"xcodebuild",
3538
"-project",
3639
parameters.xcodeprojPath.get(),
3740
"-showBuildSettings"
3841
)
3942
it.standardOutput = buildDirOutput
43+
it.errorOutput = errOutput
4044
}
41-
val buildSettings = buildDirOutput.toString("UTF-8")
42-
val buildDirMatch = buildDirRegex.find(buildSettings)
43-
val buildDir = buildDirMatch?.groupValues?.get(1)
44-
if (buildDir == null || buildDir.contains("DerivedData").not()) {
45+
46+
if (execOperations.exitValue == 0) {
47+
val buildSettings = buildDirOutput.toString("UTF-8")
48+
val buildDirMatch = buildDirRegex.find(buildSettings)
49+
val buildDir = buildDirMatch?.groupValues?.get(1)
50+
if (buildDir == null || buildDir.contains("DerivedData").not()) {
51+
return null
52+
}
53+
return buildDir.replace("/Build/Products", "")
54+
} else {
55+
logger.warn(
56+
"Failed to retrieve derived data path. xcodebuild command failed. Error output: ${
57+
errOutput.toString(
58+
Charsets.UTF_8
59+
)
60+
}"
61+
)
4562
return null
4663
}
47-
return buildDir.replace("/Build/Products", "")
4864
}
4965
}

0 commit comments

Comments
 (0)