Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

package of cinterop dependency (Swift framework) not found in the iOSMain sources set #4543

Closed
RoqueCampos opened this issue Nov 19, 2020 · 1 comment

Comments

@RoqueCampos
Copy link

I'm trying to import and use a self made Swift framework in a kotlin native shared code module, for the iOS sources set. I followed the guide to add a dependency to the iOS Sourceset: https://kotlinlang.org/docs/mobile/add-dependencies.html#without-cocoapods

The version of the kotlin gradle plugin I'm using is 1.4.10, and Android Studio 4.2 Canary 15. The project was started with the KMM template with the wizard.

The shared code module builds correctly, and in the external libraries hierarchy in android studio I can see the generated .klib libraries:

image

The content of the .knm files seems correct too:

image

But when I try to import this package in the a class of the iOSMain source set, the package is not resolved:

image

This is my def file:

language = Objective-C
modules = SlicerUtils
package = com.xxxxx.iosframeworks

And this is an extract of the build.gradle.kts file where the cinterop are defined:

    val iosFrameworkBaseDir = "${projectDir}/../../ios-frameworks"
    val slicerUtilsDir = file("$iosFrameworkBaseDir/SlicerUtils").absolutePath


    val slicerUtilsBaseFrameworkDirX64 =
        file("$slicerUtilsDir/DerivedData/SlicerUtils/Build/Products/Debug-iphonesimulator").absolutePath

    val slicerUtilsBaseFrameworkDirArm64 =
        file("$slicerUtilsDir/DerivedData/SlicerUtils/Build/Products/Debug-iphoneos").absolutePath



    iosX64() {
        compilations.getByName("main") {
            val slicerUtils by cinterops.creating {
                defFile("SwiftSlicerUtils.def")
                compilerOpts(
                    "-framework",
                    "SlicerUtils",
                    "-F$slicerUtilsBaseFrameworkDirX64/"
                ) //As framework

            }

        }

        binaries.all {
            // Linker options required to link to the framework.
            linkerOpts("-framework", "SlicerUtils", "-F${slicerUtilsBaseFrameworkDirX64}/")
        }
    }

    iosArm64() {
        compilations.getByName("main") {
            val slicerUtils by cinterops.creating {
                defFile("SwiftSlicerUtils.def")
                compilerOpts(
                    "-framework",
                    "SlicerUtils",
                    "-F$slicerUtilsBaseFrameworkDirArm64/"
                )//As framework

            }

        }

        binaries.all {
            // Linker options required to link to the framework.
            linkerOpts("-framework", "SlicerUtils", "-F${slicerUtilsBaseFrameworkDirArm64}/")
        }
    }
  

I don't think it is a problem with the cinterop definition in the build.gradle.kts file, because the paths are correct and the shared code module builds without errors.

May somebody give me a clue?

@RoqueCampos RoqueCampos changed the title package of cinterop dependency (Swift framework) not found in the iOSMain sources package of cinterop dependency (Swift framework) not found in the iOSMain sources set Nov 19, 2020
@SvyatoslavScherbina
Copy link
Collaborator

Probably a duplicate of KT-40975. Try switching the kotlin.native.enableDependencyPropagation value in your gradle.properties file.
In any case, please stop using GitHub issues of this repository for anything and prefer other ways of getting some help: #4079

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants