Skip to content

Commit

Permalink
fix(plugin): check exit value when executing xcodebuild command (#326)
Browse files Browse the repository at this point in the history
* add error logging

* update CHANGELOG
  • Loading branch information
buenaflor authored Feb 10, 2025
1 parent 4132cdd commit 06ffaf6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.kotlin.multiplatform.gradle

import io.sentry.kotlin.multiplatform.gradle.SentryPlugin.Companion.logger
import org.gradle.api.provider.Property
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
Expand Down Expand Up @@ -29,21 +30,36 @@ abstract class DerivedDataPathValueSource :

override fun obtain(): String? {
val buildDirOutput = ByteArrayOutputStream()
execOperations.exec {
val errOutput = ByteArrayOutputStream()

val execOperations = execOperations.exec {
it.commandLine = listOf(
"xcodebuild",
"-project",
parameters.xcodeprojPath.get(),
"-showBuildSettings"
)
it.standardOutput = buildDirOutput
it.errorOutput = errOutput
}
val buildSettings = buildDirOutput.toString("UTF-8")
val buildDirMatch = buildDirRegex.find(buildSettings)
val buildDir = buildDirMatch?.groupValues?.get(1)
if (buildDir == null || buildDir.contains("DerivedData").not()) {

if (execOperations.exitValue == 0) {
val buildSettings = buildDirOutput.toString("UTF-8")
val buildDirMatch = buildDirRegex.find(buildSettings)
val buildDir = buildDirMatch?.groupValues?.get(1)
if (buildDir == null || buildDir.contains("DerivedData").not()) {
return null
}
return buildDir.replace("/Build/Products", "")
} else {
logger.warn(
"Failed to retrieve derived data path. xcodebuild command failed. Error output: ${
errOutput.toString(
Charsets.UTF_8
)
}"
)
return null
}
return buildDir.replace("/Build/Products", "")
}
}

0 comments on commit 06ffaf6

Please sign in to comment.