multiplatform-swiftpackage icon indicating copy to clipboard operation
multiplatform-swiftpackage copied to clipboard

Middle nativeMain module with specific iosMain and macOSMain fails.

Open checoalejandro opened this issue 3 years ago • 0 comments

Not sure if this is expected, do have a project with a middle nativeMain source set for specific iosMain & macOSMain source set

- commonMain
    - nativeMain
        - iosMain
        - macOSMain

build.gradle.kts

    macosX64("native")
    macosX64("macOS") {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    ios() {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }

    ...

    val nativeMain by getting {
        dependencies {
            implementation(libs.sqlDelight.native)
            implementation(libs.ktor.client.core)
            implementation(libs.coroutines.core)
            implementation(libs.multiplatformSettings.common)
        }
    }
    val iosMain by getting {
        dependsOn(nativeMain)
        dependencies {
            implementation(libs.ktor.client.ios)
            val coroutineCore = libs.coroutines.core.get()
            implementation("${coroutineCore.module.group}:${coroutineCore.module.name}:${coroutineCore.versionConstraint.displayName}") {
                version {
                    strictly(libs.versions.coroutines.native.get())
                }
            }
        }
    }
    val macOSMain by getting {
        dependsOn(nativeMain)
        dependencies {
            implementation("io.ktor:ktor-client-curl:2.0.0-beta-1")
        }
    }

...

multiplatformSwiftPackage {
    packageName("sharedValkyrie")
    swiftToolsVersion("5.3")
    targetPlatforms {
        iOS { v("13") }
        macOS { v("11") }
    }
}

Inside commonMain I have multiple expect class ... that are defined only in iosMain and macOSMain and not in nativeMain, such as UserAgent strings, platform name, etc. After gradle sync, those expect classes are solved properly without any errors but when running createSwiftPackage gradle task, I receive that there are no expect declarations in nativeMain module: Expected class 'Platform' has no actual declaration in module <mySharedModule> for Native

Shouldn't just execute compileKotlinIos and compileKotlinMacOS and skip compileKotlinNative? Is there a workaround to do this?

checoalejandro avatar Jan 28 '22 03:01 checoalejandro