has anyone added a cinterop (Obj-C framework) to a...
# multiplatform
k
has anyone added a cinterop (Obj-C framework) to a test executable?
s
I’ve imported the framework into an Xcode project that uses it to run its unit tests, not sure if that fits what you are describing
k
that's kind of the opposite
MPP output -> iOS unit tests instead of iOS framework -> MPP unit tests
i managed to accomplish this by building both a dynamic and static framework, grabbing the headers from the dynamic framework, and throwing them in a directory with the static framework library
kind of kludgy, but whatever
d
We're looking at testing now as well. Can you post your build file to do what you described?
k
i'll post the relevant section, but it's only one piece of the puzzle
Copy code
iosX64("ios") {
        compilations {
            "main" {
                dependencies {
                    implementation("suparnatural-kotlin-multiplatform:fs-iosx64:$suparnaturalVersion")
                }
            }
            "test" {
                cinterops.create("OHHTTPStubs") {
                    includeDirs("c_interop/OHHTTPStubs/Headers")
                }
            }
        }
        binaries.getTest(DEBUG).linkerOpts("-Lc_interop/OHHTTPStubs")
    }
k
I’ve built a test framework in the past, but don’t currently have that wired up. If you pass “-tr” into the compiler it’ll generate a test runner. You can call that entry point from swift/objc, and it’ll run the tests.
k
to be clear, I just wanted to link my existing text executable (the default one) to an obj-c framework
it needs to be static