New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one Kotlin framework can be loaded currently #2423

Open
solivares1 opened this Issue Nov 26, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@solivares1
Copy link

solivares1 commented Nov 26, 2018

So.. i managed to make two kotlin-native frameworks for Swift but when trying to add them on the project i got the following message.
(Only one Kotlin framework can be loaded currently)

Do we have any update on this?
I prefer not to merge both frameworks into one, is there another workaround?

@SvyatoslavScherbina

This comment has been minimized.

Copy link
Contributor

SvyatoslavScherbina commented Nov 27, 2018

I prefer not to merge both frameworks into one

What's the reason behind this?
Do these frameworks have something in common? Does one of these frameworks depend on the other one?

@solivares1

This comment has been minimized.

Copy link

solivares1 commented Nov 27, 2018

@SvyatoslavScherbina They don't depend on each other nor have something in common, and both of those frameworks can be used in other apps.
So if i merge them when i create the .framework it will have unnecessary code from the unused one.

I think there's a workaround, creating tasks in the build.gradle to adjust for specific needs like, build A, build B or build A&B in only one .framework

But thats not optimal, we can't share several kotlin-native created libraries if we can't use more than one Kotlin framework per project

@kylejbrock

This comment has been minimized.

Copy link

kylejbrock commented Nov 27, 2018

@solivares1 That's what I've had to do to utilize multiple kotlin libraries as a single framework:

I actually support several apps, needing different features. They are both ios & android apps.

So, I've ended up with a function in gradle called: isPlatformTypeEnabled and another called isFeatureEnabled.

Then I have a block that looks similar to this:

if (isPlatformTypeEnabled("client") && isPlatformTypeEnabled("ios")) {
            iosMain {
                kotlin {
                    if (isFeatureEnabled("localization")) {
                        srcDir("$projectDir/src/localization/iosMain/kotlin")
                        srcDir("$projectDir/src/localization/mobileMain/kotlin")
                    }
                }
                dependencies {
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
                }
            }
            iosTest {
                dependencies {
                    implementation 'org.jetbrains.kotlin:kotlin-test'
                    implementation 'org.jetbrains.kotlin:kotlin-test-junit'
                }
            }
        }

This enables me to dynamically include different source sets based on what I pass to the gradle build.

It's definitely not ideal, but it's a sufficient work around.

This yields a single framework per application/platform. But, with the appropriate feature sets per application/platform.

@SvyatoslavScherbina

This comment has been minimized.

Copy link
Contributor

SvyatoslavScherbina commented Nov 29, 2018

@solivares1 thank you for providing the details.
I suppose this case makes sense and can be eventually supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment