Skip to content

Commit

Permalink
Merge pull request #947 from MarathonLabs/fix/watch-app-detection
Browse files Browse the repository at this point in the history
fix(apple): handle watch app if it's defined in the app bundle
  • Loading branch information
Malinskiy authored Jun 18, 2024
2 parents f990013 + 26f4f1b commit 7e1b78a
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ data class AppleTestBundleConfiguration(
) {
@JsonIgnore
var app: File? = null

@JsonIgnore
var testApp: File? = null

@JsonIgnore
lateinit var xctest: File

Expand Down Expand Up @@ -90,7 +92,23 @@ data class AppleTestBundleConfiguration(
}
when {
found.isEmpty() && validate -> throw ConfigurationException("Unable to find an $extension directory in ${directory.absolutePath}")
found.size > 1 -> throw ConfigurationException("Ambiguous $extension configuration in derived data folder [${found.joinToString { it.absolutePath }}]. Please specify parameters explicitly")
found.size == 2 -> {
//According to https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle watch app will be placed
//under X.app/Watch/Y.app
//Consider only the X.app for such case

val a = found.removeFirst()
val b = found.removeFirst()
return if (a.relativeTo(b).toPath().firstOrNull()?.toString() == "Watch") {
b
} else if (b.relativeTo(a).toPath().firstOrNull()?.toString() == "Watch") {
a
} else {
throw ConfigurationException("Ambiguous $extension configuration in derived data folder [${found.joinToString { it.absolutePath }}]. Please specify parameters explicitly")
}
}

found.size > 2 -> throw ConfigurationException("Ambiguous $extension configuration in derived data folder [${found.joinToString { it.absolutePath }}]. Please specify parameters explicitly")
}
return found.firstOrNull()
}
Expand Down

0 comments on commit 7e1b78a

Please sign in to comment.