icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
994 stars 95 forks source link

Library not loaded error for compose multiplatform #245

Closed kinber95 closed 1 year ago

kinber95 commented 1 year ago

Since May you can use Compose code for your iOS App (Alpha), I try to set it up with the moko mvvm library but I get this error:

dyld[5454]: Library not loaded: @rpath/MultiPlatformLibrary.framework/MultiPlatformLibrary
  Referenced from: <5B516538-D320-3672-AFBC-B6B52E5DA96B> /Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/mokoMvvmFlowSwiftUI.framework/mokoMvvmFlowSwiftUI
  Reason: tried: '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/mokoMvvmFlowSwiftUI.framework/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/usr/lib/swift/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file, not in dyld cache), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/usr/lib/swift/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file, not in dyld cache), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Users/bjoern.kinberger/Library/Developer/CoreSimulator/Devices/251B96F9-700E-4DD4-9932-D53BA6F9FB02/data/Containers/Bundle/Application/A82E436A-505F-472E-A724-8C89B857E3D9/iosApp.app/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MultiPlatformLibrary.framework/MultiPlatformLibrary' (no such file)

cocoapods set up in gradle

    val mokoMvvmVersion = "0.16.1"

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "MultiPlatformLibrary"
            isStatic = true
            export("dev.icerock.moko:mvvm-core:$mokoMvvmVersion")
            export("dev.icerock.moko:mvvm-flow:$mokoMvvmVersion")
        }
    }

Note: You need to use isStatic = true, otherwise the compose code is not found in the iOS Module

The versions I use:

I tried some of the other solutions, but there are not compatible with the new compose feature.

Alex009 commented 1 year ago

hello. compiled cocoapod with swiftui additions require dynamic framework. you use static. you can just copy this swift files https://github.com/icerockdev/moko-mvvm/tree/master/mvvm-flow/apple/xcode/mokoMvvmFlowSwiftUI inside your project. and remove mokoMvvmFlowSwiftUI cocoapod

kinber95 commented 1 year ago

Thanks for the fast reply, I added all the files but Xcode can't find the StringDesc type in ViewModelStateNullable. I try to add the flow-resources module, but that didn't help.

Alex009 commented 1 year ago

did you add moko-resources to export list? also if you not use StringDesc - you can just remove this extensions

kinber95 commented 1 year ago

Yea but that didn't help, so I just remove this extensions. Thanks for the help