fixup! [Gradle] Add .xcodeproj configuration checker
diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/apple/CheckXcodeTargetsConfigurationTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/apple/CheckXcodeTargetsConfigurationTask.kt
index dd11d26..60c7db9 100644
--- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/apple/CheckXcodeTargetsConfigurationTask.kt
+++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/apple/CheckXcodeTargetsConfigurationTask.kt
@@ -42,13 +42,25 @@
* while the cheap validation task runs whenever the JSON changes, consistently re-issuing warnings.
*/
internal val CheckXcodeTargetsConfigurationSetupAction = KotlinProjectSetupCoroutine {
+ // 1. Check if there are any apple targets with frameworks. If not, the check is not needed.
if (!shouldSetupXcodeConfiguration()) {
return@KotlinProjectSetupCoroutine
}
- val appleTargets = getAppleTargetsWithFrameworkBinaries()
- val projectPath = project.xcodeProjectPath ?: return@KotlinProjectSetupCoroutine
+ // 2. Check for the Xcode project path. If it's not found, log an informational message.
+ val projectPath = project.xcodeProjectPath
+ if (projectPath == null) {
+ val searchedPaths = project.xcodeProjectSearchedPaths
+ logger.info(
+ "Kotlin Xcode project checker: .xcodeproj directory not found. Searched in:\n" +
+ searchedPaths.joinToString("\n") { " - ${it.path}" } +
+ "\nSkipping task registration."
+ )
+ return@KotlinProjectSetupCoroutine
+ }
+ // 3. If everything is in place, register the tasks.
+ val appleTargets = getAppleTargetsWithFrameworkBinaries()
val convertTask = registerConvertPbxprojToJsonTask(projectPath)
registerCheckXcodeTargetsConfigurationTask(appleTargets, projectPath, convertTask)
}
@@ -365,16 +377,14 @@
else -> unknownSdkRoot
}
-private val Project.xcodeProjectPath: File?
+private val Project.xcodeProjectSearchedPaths: List<File>
get() {
- // A heuristic to find the `.xcodeproj` directory.
- // It's not guaranteed to work for all project structures.
val commonPath = "iosApp/iosApp.xcodeproj"
- val iosProject = layout.projectDirectory.asFile.resolve(commonPath)
- if (iosProject.exists()) return iosProject
-
- val rootProjectIos = rootDir.resolve(commonPath)
- if (rootProjectIos.exists()) return rootProjectIos
-
- return null
+ return listOf(
+ layout.projectDirectory.asFile.resolve(commonPath),
+ rootDir.resolve(commonPath)
+ )
}
+
+private val Project.xcodeProjectPath: File?
+ get() = xcodeProjectSearchedPaths.firstOrNull { it.exists() }