Closed hardysim closed 4 years ago
It seems to work when I do not use cocoapods but export a framework to use the shared/kotlin-code in swift (using packForXCode
from the kotlin-mpp examples).
Is this a bug? Should this library work when the shared code is exported as a cocoapod?
hello!
it's strange that usage of cocoapods have some changes. we use in our projects integration by cocoapods. but not official kotlin plugin - we create own podspec
file and it use sync
task from https://github.com/icerockdev/mobile-multiplatform-gradle-plugin
same configuration used in sample of moko-resources
.
error said what bundle
with resources not found in application at runtime. reason of it now i don't know.
i hope this sample project https://github.com/icerockdev/moko-resources/issues/97#issuecomment-676097851 will help me to debug this problem.
fix will be available in 0.12.0 or 0.12.1 versions, with kotlin 1.4.0 support
The error is gone in 0.11.1 but a new one arises:
Uncaught Kotlin exception: kotlin.IllegalArgumentException: bundle with identifier com.example.demo.MR not found
Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift.
Other exceptions can be propagated as NSError if method has or inherits @Throws annotation.
Uncaught Kotlin exception: kotlin.IllegalArgumentException: bundle with identifier com.example.demo.MR not found
at 0 iosApp 0x000000010726ca87 kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable + 87
at 1 iosApp 0x000000010725f855 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85
at 2 iosApp 0x000000010725fa75 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85
at 3 iosApp 0x000000010725fe95 kfun:kotlin.IllegalArgumentException.<init>(kotlin.String?)kotlin.IllegalArgumentException + 85
at 4 iosApp 0x000000010816149a kfun:dev.icerock.moko.resources.utils.loadableBundle@platform.Foundation.NSBundle.Companion.(kotlin.String)platform.Foundation.NSBundle + 4474
at 5 iosApp 0x0000000106f20d32 kfun:com.example.demo.MR.<init>$lambda-0#internal + 162
at 6 iosApp 0x0000000106f20e54 kfun:com.example.demo.MR.$<init>$lambda-0$FUNCTION_REFERENCE$1.invoke#internal + 132
at 7 iosApp 0x00000001072b887c kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.getOrInit#internal + 1004
at 8 iosApp 0x00000001072b8fa9 kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.<get-value>()T + 393
at 9 iosApp 0x0000000106f1ff73 kfun:com.example.demo.MR.<get-bundle>#internal + 323
at 10 iosApp 0x0000000106f2011c kfun:com.example.demo.MR.strings.<init>()com.example.demo.MR.strings + 268
at 11 iosApp 0x0000000107693a85 InitSharedInstanceStrict + 197
at 12 iosApp 0x0000000106f3381e kfun:com.example.demo.feature.arcadelist.ArcadeListViewModel.<init>(com.example.demo.feature.arcadelist.LoadArcadesUseCase;com.example.demo.feature.arcadelist.GetArcadeUseCase;com.example.demo.feature.arcadelist.RemoveArcadeUseCase)com.example.demo.feature.arcadelist.ArcadeListViewModel + 1342
at 13 iosApp 0x0000000106f31993 kfun:com.example.demo.di.InjectorUtils.provideArcadeListViewModel(com.example.demo.repository.Repository)com.example.demo.feature.arcadelist.ArcadeListViewModel + 691
at 14 iosApp 0x0000000106f44d13 objc2kotlin.115 + 275
at 15 iosApp 0x0000000106b59b8c $s6iosApp24ArcadeListViewControllerC7nibName6bundleACSSSg_So8NSBundleCSgtcfcTo + 172 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/<compiler-generated>:<unknown>)
at 16 iosApp 0x0000000106b5bcd3 $sSo16UIViewControllerCABycfcTO + 19 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/<compiler-generated>:<unknown>)
at 17 iosApp 0x0000000106b5bc6f $sSo16UIViewControllerCABycfC + 31 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/<compiler-generated>:<unknown>)
at 18 iosApp 0x0000000106b5b7b7 $s6iosApp0B8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 183 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/<compiler-generated>:<unknown>)
at 19 iosApp 0x0000000106b5be23 $s6iosApp0B8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 211 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/<compiler-generated>:<unknown>)
at 20 UIKitCore 0x00007fff4931c614 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
at 21 UIKitCore 0x00007fff4931dfb3 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3985
at 22 UIKitCore 0x00007fff49323b75 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1226
at 23 UIKitCore 0x00007fff48a2c1a6 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179
at 24 UIKitCore 0x00007fff49320063 -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59
at 25 UIKitCore 0x00007fff49320362 -[UIApplication _run] + 754
at 26 UIKitCore 0x00007fff49325968 UIApplicationMain + 1605
at 27 iosApp 0x0000000106b5cd1b main + 75 (/Users/AppTeam/Desktop/projects/multiplatform/arcade/iosApp/iosApp/Navigation/AppDelegate/AppDelegate.swift:13:7)
at 28 libdyld.dylib 0x00007fff520ce1fd start + 1
at 29 ??? 0x0000000000000001 0x0 + 1
(lldb)
I've ran all gradle tasks to generate MR (generateMRandroidMain
, generateMRcommonMain
, generateMRiosArm64Main
, generateMRiosX64Main
) and it still works on android.
Is this a followup or should I create a new issue?
@hardysim hi! thanks for you feedback. please help with fix - can you give me project reproducer with problem? something in configuration of your project is reason of bug, i need to debug it
Here is a minimal project that demonstrates the bug: https://github.com/dalewking/moko_bug
Just run ./gradlew iosTest and you will get a test failure:
kotlin.IllegalArgumentException: bundle with identifier org.example.library.MR not found
@dalewking your project does not use cocoapods, right? I only geht this error when using cocoapods. Strange that you get the same error...
All I did was use IntelliJ to generate a MPP project and added Moko Resources and a dummy test to it to get tests to actually run. Our actual project uses cocoapods and gets the same error.
@hardysim reproducer given @dalewking is only for tests (output after compilation is kexe, not framework, so resources bundle not provided). can you give me reproducer of your case?
@hardysim reproducer given @dalewking is only for tests (output after compilation is kexe, not framework, so resources bundle not provided). can you give me reproducer of your case?
Even though it is tests it still needs to work
@hardysim in 0.12.0 release you can use cocoapods plugin, but you should add some script in Xcode project. Please read new readme and try new version.
@Alex009 After playing around a bit, I am stuck with the XCode config. I am using this example with their cocoapods plugin fork and added the build phase mentioned here to my project. Unfortunately, XCode outputs the error Task 'copyFrameworkResourcesToApp' not found in project ':shared'.
. Could you give me a hint what I am missing?
I also looked at the samples and added this block, but I didn't find what I am missing.
@ln-12 maybe you can share project? i will see and try fix
@Alex009 Thanks for your offer! I uploaded a minimal project here which I quickly copied together to get the same error. The two commit show the different errors I get before and after adding the build phase script to XCode. Now I'm stuck with Task 'copyFrameworkResourcesToApp' not found in project ':shared'.
.
@ln-12 hi! in your case plugins apply is order-dependend. i fix your setup here - https://github.com/ln-12/moko-resources-issue-99/pull/1
reason of unexist task is that co.touchlab.native.cocoapods
change isStatic
field of Framework
in configuration time...but our plugin can't observe this action (and i not think that it is real)
Oh no, I am feeling really stupid now for such a mistake. Thanks a thousand times four your help!!
Hi @Alex009, I'm facing same crash (IllegalArgumentException: bundle with identifier com.well.myapplication.MR not found
).
My sample project: https://github.com/PhilipDukhov/testCocoapodsKMM/tree/moko-resources-test
I'm using cocoapods plugin, and according to the docs, I need to pass extra properties
to the script call, but how can I do it, if podspec file gets regenerated after each gradle sync? Also adding those manually didn't helped with this issue.
@PhilipDukhov you should not edit generated podspec. you should edit your xcode project settings. just like in sample at target TestHierarhical:
I'm getting a crash on iOS when trying to show a string. Following the README and calling
getMyString()
works fine on android but crashes on iOS with the following stacktrace:I've added
CFBundleLocalizations
to the plist-file so I'm not sure whats wrong. The sample is working as well as a clean project but not my existing one where I need this.