Travis Reitter

    8 months ago
    I just switched to
    to build my iOS app (Kotlin 1.6.10, M1 Mac, Xcode 13.2.1) and I hit this crash at runtime which seems to indicate a linking error but I'm not sure why since I include this in my Frameworks search paths:
    The error is:
    dyld[28834]: Library not loaded: @rpath/SharedCode.framework/SharedCode
      Referenced from: /Users/treitter/Library/Developer/CoreSimulator/Devices/A5638492-9E3A-4766-B4D4-6827DF4DBAC8/data/Containers/Bundle/Application/CADE4DEF-489A-4E7F-B600-8CFAA803F19D/DoubleStrain <http://dev.app/DoubleStrain|dev.app/DoubleStrain> dev
      Reason: tried: '/Users/treitter/Library/Developer/Xcode/DerivedData/DoubleStrain-csfvqjqyopvjufbkvgenmyhjexpz/Build/Products/Debug-iphonesimulator/SharedCode.framework/SharedCode' (no such file), '/Users/treitter/Library/Developer/Xcode/DerivedData/DoubleStrain-csfvqjqyopvjufbkvgenmyhjexpz/Build/Products/Debug-iphonesimulator/PackageFrameworks/SharedCode.framework/SharedCode' (no such file),
    it continues on with many more directories it checked but none of them match the pattern above. None even include
    in the path. Any ideas for debugging?

    Dmitry Motyl

    4 months ago
    @Travis Reitter I have the same problem did you figure out it ?

    Travis Reitter

    4 months ago
    @Dmitry Motyl yes but I'm not sure exactly what the fix was, but I believe it's possibly related to the way I set up my
    for my KMM project (see the functions at the top):
    kotlin {
        android {
        fun isIphoneSimulatorBuild(): Boolean =
            System.getenv("NATIVE_ARCH") == "arm64" && System.getenv("SDK_NAME")?.startsWith("iphonesimulator") == true
        fun isIphoneOsBuild(): Boolean =
            System.getenv("SDK_NAME")?.startsWith("iphoneos") == true
        val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
            when {
                isIphoneSimulatorBuild() -> ::iosSimulatorArm64
                isIphoneOsBuild() -> ::iosArm64
                else -> ::iosX64
        iosTarget("ios") {
            val sdkName = when {
                isIphoneSimulatorBuild() -> "iphonesimulator"
                isIphoneOsBuild() -> "iphoneos"
                else -> "x86"
            binaries {
                framework {
                    baseName = "shared"
    I had to propose a similar fix for a different project to build correctly on M1. I've tried to simplify it a number of ways but it never worked
    good luck!