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

Can't run app in simulator/device because of error "Library not loaded: MultiPlatformLibrary" #223

Closed lcsphantom closed 1 year ago

lcsphantom commented 1 year ago

I'm currently using KMP in my project however I am getting the following error after installing moko mvvm pod.

Library not loaded: @rpath/MultiPlatformLibrary.framework/MultiPlatformLibrary
  Referenced from: <88C26753-2490-3706-AD1F-2B70235B03C0> /Users/myuser/Library/Developer/CoreSimulator/Devices/FF2AB24A-D43D-4FA5-8EA6-1EC35F534175/data/Containers/Bundle/Application/E7A5224E-EDC6-429C-B7F6-75626CF06A7A/iosApp.app/iosApp
  Reason: tried: '/Users/myuser/Library/Developer/Xcode/DerivedData/iosApp-bgwjzwiytpqhzyfafcmzfquerttr/Build/Products/Debug-iphonesimulator/MultiPlatformLibrary.framework/MultiPlatformLibrary' (errno=2),
...

Which seems to be the same issue as which is not a duplicate of this.

I'm running xcode 14.1 (14B47b).

The only way I found to fix the issue is to go into shared build.gradle.kts and change: cocoapods { ... framework { baseName = "MultiPlatformLibrary" isStatic = false ... } }

The param baseName must match what is being used by moko which is MultiPlatformLibrary, any other name and the xcode project will throw an error on runtime.