Skip to content
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

Will generated code work or not depends on the project structure #6

Open
dasdranagon opened this issue Sep 8, 2021 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@dasdranagon
Copy link
Contributor

Currently, in documentation, nothing in the documentation said what the project structure should be to make generated code work. I have found few cases when it doesn't work.

It works if kaluga:resourses imported in a shared project and was not exported to a framework.

It doesn't work if

  • kaluga:resourses was exported to a framework
  • We have a base project and kaluga:resourses was imported there, then the subproject was exported as a framework.

A concrete example.

We have a project with structure:

Root project 'SplendoHealth'
+--- Project ':fit'
+--- Project ':shared'
...
./gradlew :fit:dependencies | grep -E 'shared|resources'
...
+--- project :shared
|    +--- com.splendo.kaluga:resources:0.2.1
|    |    \--- com.splendo.kaluga:resources-iosarm64:0.2.1
....

In build.gradle.kts(:shared):

kotlin {
...
 sourceSets {
        commonMain {
            dependencies {
                  api("com.splendo.kaluga:resources:$kalugaVersion")
            }
        }
        .....
}

In build.gradle.kts(:fit):

kotlin {
      commonMain {
            dependencies {
                api(project(":shared"))
            }
     }
}

This structure will work with kaluga-swiftui

Now let's assume we have some code in shared we want to export in the framework. So we add such configuration in build.grade(:fit):

    val target: KotlinNativeTarget.() -> Unit =
        {
            binaries {
                framework {
                    isStatic = false
                    transitiveExport = true
                    export(project(":shared"))

                    linkerOpts("-F${rootProject.projectDir}/ios/Carthage/Build/iOS/")
                    linkerOpts("-ObjC")
                }
            }
        }

This structure will NOT work with kaluga-swiftui

The project will not compile because it will not find ResourcesColor

@Daeda88
Copy link
Contributor

Daeda88 commented Sep 10, 2021

We'll have to make resources a configuration flag. I want to do this for button styles anyway. Should be an easy fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants