t

    Travis Reitter

    8 months ago
    I just switched to
    embedAndSignAppleFrameworkForXcode
    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:
    $(SRCROOT)/../SharedCode/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)
    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
    xcode-frameworks
    in the path. Any ideas for debugging?
    d

    Dmitry Motyl

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

    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
    build.gradle.kts
    for my KMM project (see the functions at the top):
    kotlin {
        android {
            publishAllLibraryVariants()
        }
    
        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!