Hi! Is there someone who have experience with coco...
# kotlin-native
a
Hi! Is there someone who have experience with cocoapods plugin and running tests targeting the iOS target. It seem like the linker can't see the imported frameworks when generating the test executable. Does anyone have the same issue?
Copy code
> Task :shared:firebase:auth:linkDebugTestIosX64 FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FIRAuthDataResult", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIRAuth", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIREmailAuthProvider", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIRAuthTokenResult", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_FIRUser", referenced from:
      objc-class-ref in result.o
  "_FIRAuthErrorDomain", referenced from:
      _cocoapods_FirebaseAuth_FIRAuthErrorDomain_getter_wrapper0 in result.o
ld: symbol(s) not found for architecture x86_64
FAILURE: Build failed with an exception.
the build tasks succeeds for both Arm64 and X64, but the iosX64 test fails to link
a
hi. i use this config to add frameworks path into linker and later load frameworks in runtime for tests:
Copy code
val frameworksPath = "${buildDir.absolutePath}/cocoapods/UninstalledProducts/iphonesimulator"
kotlin {
    targets
        .filterIsInstance<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>()
        .forEach { target ->
            target.binaries.forEach { binary ->
                binary.linkerOpts("-F$frameworksPath")
            }
        }
}

// now standard test task use --standalone but it broke network calls
with(tasks.replace("iosX64Test")) {
    val linkTask = tasks.getByName("linkDebugTestIosX64") as org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
    dependsOn(linkTask)
    group = JavaBasePlugin.VERIFICATION_GROUP
    description = "Runs tests for target 'ios' on an iOS simulator"

    doLast {
        val binary = linkTask.binary.outputFile
        val device = "iPhone 8"
        exec {
            commandLine = listOf("xcrun", "simctl", "boot", device)
            isIgnoreExitValue = true
        }
        exec {
            environment("SIMCTL_CHILD_DYLD_FRAMEWORK_PATH", frameworksPath)
            commandLine = listOf(
                "xcrun",
                "simctl",
                "spawn",
                device,
                binary.absolutePath
            )
        }
        exec {
            commandLine = listOf("xcrun", "simctl", "shutdown", device)
        }
    }
}