KmpComposeUIViewControllerPlugin

class KmpComposeUIViewControllerPlugin : Plugin<Project>

Heavy lifts Gradle configurations when using KMP-ComposeUIViewController library.

Exposes the following tasks under the composeuiviewcontroller group:

  • copyFilesToXcode — syncs KSP-generated Swift Representables to iosApp/Representables/ and updates the Xcode project references. Triggered automatically after embedAndSignAppleFrameworkForXcode, embedSwiftExportForXcode, or syncFramework when PluginParameters.autoExport is true. Not registered when PluginParameters.experimentalSpmExport is true.

  • exportToSpm — experimental. Creates and maintains a local SPM package at iosApp/Representables/ (folder names driven by PluginParameters.iosAppFolderName and PluginParameters.exportFolderName). Triggered automatically after embedSwiftExportForXcode when PluginParameters.experimentalSpmExport is true. Requires Swift Export to be configured.

  • formatSwiftFiles — formats generated .swift files with swiftformat default rules (if available).

  • validateRepresentables — inspects the full Representables pipeline without triggering a build. Useful for diagnosing why Xcode cannot find generated UIViewControllerRepresentable files. Run it with ./gradlew validateRepresentables. Reports OK, WARN, or FAIL for each check:

CheckWhat it verifiesFails when
KSP output.swift files exist in build/generated/ksp/KSP never ran or failed mid-generation
Destination.swift files exist in iosApp/Representables/copyFilesToXcode did not run
SyncKSP output and destination contain the same filesFiles are stale or missing
xcodeprojAll Representables are referenced in project.pbxprojrebuild_file_references failed

WARN entries (stale destination files, xcodeproj not found) do not fail the task. FAIL entries throw a GradleException listing all errors. The most common fix is ./gradlew clean. The xcodeproj check is skipped when PluginParameters.autoExport is false.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open override fun apply(project: Project)