KmpComposeUIViewControllerPlugin
Heavy lifts Gradle configurations when using KMP-ComposeUIViewController library.
Exposes the following tasks under the composeuiviewcontroller group:
exportToSpm— default. Creates and maintains a local SPM package atiosApp/Representables/(folder names driven by PluginParameters.iosAppFolderName and PluginParameters.exportFolderName). Triggered automatically afterembedAndSignAppleFrameworkForXcode,embedSwiftExportForXcode, orsyncFrameworkwhen PluginParameters.autoExport istrue. Not registered when PluginParameters.legacyMode istrue. Requires a one-time setup viacreateRepresentablesPackage(the plugin warns automatically if this hasn't been run yet).createRepresentablesPackage— one-time setup for the SPM package: creates the stubPackage.swiftand adds the package reference to the Xcode project. Not registered when PluginParameters.legacyMode istrue.deleteRepresentablesPackage— reversescreateRepresentablesPackage. Always manual — never run automatically.copyFilesToXcode— legacy. Syncs KSP-generated Swift Representables toiosApp/Representables/and updates the Xcode project references by manipulatingproject.pbxprojdirectly on every build. Only registered when PluginParameters.legacyMode istrue.formatSwiftFiles— formats generated.swiftfiles withswiftformatdefault rules (if available).validateRepresentables— inspects the full Representables pipeline without triggering a build. Useful for diagnosing why Xcode cannot find generatedUIViewControllerRepresentablefiles. Run it with./gradlew validateRepresentables. ReportsOK,WARN, orFAILfor each check, adapting to whichever mode (PluginParameters.legacyMode or the default SPM mode) is active:
| Check | What it verifies | Fails when |
|---|---|---|
| KSP output | .swift files exist in build/generated/ksp/ | KSP never ran or failed mid-generation |
| Destination | .swift files exist in iosApp/Representables/ (or Sources/ in SPM mode) | Export task did not run |
| Sync | KSP output and destination contain the same files | Files are stale or missing |
| xcodeproj / Package.swift | Representables are referenced in project.pbxproj (legacy) or Package.swift exists (SPM) | Setup step failed |
WARN entries (stale destination files, xcodeproj/Package.swift not found) do not fail the task. FAIL entries throw a GradleException listing all errors. The most common fix is ./gradlew clean. The reference check is skipped when PluginParameters.autoExport is false.