I’m using this task in my shared module to generat...
# multiplatform
j
I’m using this task in my shared module to generate the ios framework :
Copy code
val packForXcode by tasks.creating(Sync::class) {
    val targetDir = File(buildDir, "xcode-frameworks")

    /// selecting the right configuration for the iOS
    /// framework depending on the environment
    /// variables set by Xcode build
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val framework = kotlin.targets
        .getByName<KotlinNativeTarget>("ios")
        .binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)

    from({ framework.outputDirectory })
    into(targetDir)

    /// generate a helpful ./gradlew wrapper with embedded Java path
    doLast {
        val gradlew = File(targetDir, "gradlew")
        gradlew.writeText(
            "#!/bin/bash\n"
                    + "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
                    + "cd '${rootProject.rootDir}'\n"
                    + "./gradlew \$@\n"
        )
        gradlew.setExecutable(true)
    }
}
Which seems to work, I can find it under
build > bin > ios > debugFramework > SharedCode.framework
I then go over to xcode
Target > Frameworks, Libraries, and Embedded Content > + > Add files (inside the drop box)
then I navigate to
SharedCode.framework
and select it. Xcode does not complain but when I try to build my project I get
Framework not found SharedCode
How am I suppose to add it ?
m
You might have to add it to your link phases and copy phases in XCode, let me see if I find a link
You might have to configure the framework search path

https://i.stack.imgur.com/aidyf.png

d
I was having this issue off and on and I briefly got it working by changing how the native ios target was defined, but iono - still having the missing import exception
j
still the same issue after adding
$(PROJECT_DIR)
to the search path 😞
d
What I just did now was drag and drop the framework folder that was created into the xcode project directory and now I can import shared
j
I changed the
Embed
property from
do not embed
to
embed without signing
and it works!
❤️ 2