Skip to content

Commit

Permalink
Merge pull request #2 from GuilhE/GuilhE-patch-1
Browse files Browse the repository at this point in the history
Guilh e patch 1
  • Loading branch information
GuilhE authored Sep 3, 2024
2 parents 836002c + a604037 commit 581dfab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
23 changes: 20 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,26 @@
>
> It means that the "Shared" framework will include all this external dependencies (from the "SharedModel" in this case) and will generate new types to reference those external types. That's why we endup having `Shared_modelsHello` instead of just `Hello`.
>
> To "solve" this issue we can use the export() function (inside binaries.framework configuration) to add a dependency to be exported in the framework.
Modules that provide external dependencies must include the plugin in their `build.gradle`.
> A workaround to "solve" this limitation is to use the `export()` function (inside `binaries.framework` configuration) to add a dependency to be exported in the framework.
> ```
> iosTarget.binaries.framework {
> baseName = "Shared"
> export(projects.sharedModels)
> }
> ```
> When using this approach this experimental feature should be disabled.
Modules that provide external dependencies must include the plugin in their `build.gradle`:
```
plugins {
id("io.github.guilhe.kmp.plugin-composeuiviewcontroller")
}

ComposeUiViewController {
autoExport = false
}
```
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package com.github.guilhe.kmp.composeuiviewcontroller.gradle
* @property iosAppName Name of the iOS project (name.xcodeproj)
* @property targetName Name of the iOS project's target
* @property exportFolderName Name of the destination folder inside iOS project ([iosAppFolderName]) where the Composable files will be copied to when [autoExport] is `true`
* @property autoExport Enables auto export generated files to Xcode project. If set to false, you will find the generated files under / build/ generated/ ksp/. Warning: avoid deleting [iosAppFolderName]/[exportFolderName] without first using Xcode to Remove references.
* @property autoExport Enables auto export generated files to Xcode project. If set to false, you will find the generated files under /build/generated/ksp/. Warning: avoid deleting [iosAppFolderName]/[exportFolderName] without first using Xcode to Remove references
* @property experimentalNamespaceFeature Enables experimental feature to import types from external modules. Read more in CHANGELOG.md#2020-beta1-1611-beta-4
*/
public open class ComposeUiViewControllerParameters {
/**
Expand Down Expand Up @@ -38,4 +39,4 @@ public open class ComposeUiViewControllerParameters {
* Enables experimental feature to import types from external modules. Read more in CHANGELOG.md#2020-beta1-1611-beta-4
*/
public var experimentalNamespaceFeature: Boolean = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,7 @@ internal class Processor(

/**
* Theres an [actual limitation](https://kotlinlang.slack.com/archives/C3SGXARS6/p1719961104891399) on Kotlin Multiplatform where each binary framework is compiled as a "closed world“, meaning it's not possible to pass custom type between two frameworks even it’s the same in Kotlin.
*
* Let’s say I have two modules, `shared` and `shared-models`, each providing their own binary frameworks: “Shared” and “SharedModels” respectively. The `shared-models` contains a `data class Hello`, and the `shared` module `implements(project(":shared-models"))` and has a public method that takes `Hello` as a parameter.
*
* When these modules are exported to Swift, we see the following:
*
* SharedModels: `public class Hello : KotlinBase`
*
* Shared: `public class Shared_modelsHello : KotlinBase`
*
* Shared: `open func update(state: Shared_modelsHello)`
*
* Instead of:
*
* SharedModels: `public class Hello : KotlinBase`
*
* Shared: `open func update(state: Hello)`
*
* It means that the "Shared" framework will include all this external dependencies (from the "SharedModel" in this case) sand will generate new types to reference those external types. That's why we end up having `Shared_modelsHello` instead of just `Hello`.
*
* For more information refer to CHANGELOG.md#2020-beta1-1611-beta-4
* [https://stackoverflow.com/a/78707072/1423773](https://stackoverflow.com/a/78707072/1423773)
*/
private fun buildExternalModuleParameters(moduleMetadata: List<ModuleMetadata>, imports: List<String>): MutableMap<String, String> {
Expand Down Expand Up @@ -370,4 +352,4 @@ internal class Processor(
).write(updatedCode.toByteArray())
return updatedCode
}
}
}

0 comments on commit 581dfab

Please sign in to comment.