Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin): check exit value when executing xcodebuild command #326

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,37 @@

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(

Check warning on line 55 in sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/DerivedDataPathValueSource.kt

View check run for this annotation

Codecov / codecov/patch

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

Added line #L55 was not covered by tests
"Failed to retrieve derived data path. xcodebuild command failed. Error output: ${
errOutput.toString(
Charsets.UTF_8

Check warning on line 58 in sentry-kotlin-multiplatform-gradle-plugin/src/main/java/io/sentry/kotlin/multiplatform/gradle/DerivedDataPathValueSource.kt

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L57 - L58 were not covered by tests
)
}"
)
return null
}
return buildDir.replace("/Build/Products", "")
}
}

Loading