Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access files from Swift #97

Closed
RomeuG opened this issue Jul 23, 2020 · 11 comments · Fixed by #103 or #104
Closed

Can't access files from Swift #97

RomeuG opened this issue Jul 23, 2020 · 11 comments · Fixed by #103 or #104
Assignees
Labels
bug Something isn't working
Milestone

Comments

@RomeuG
Copy link

RomeuG commented Jul 23, 2020

Hello!

This is a very similar issue to #80 .
Regardless, it is being added as Embed&Sign and yet, when I try to access the files through the debugger, I get this:

(lldb) p MR.files().testfile
error: Execution was interrupted, reason: internal c++ exception breakpoint(-4)..
The process has been returned to the state before expression evaluation.
(lldb) p MR.files().testfile
(ResourcesFileResource) $R0 = <uninitialized>
(lldb) p MR.files().testfile()
(String) $R2 = ""
(lldb) 

If I try to access it through the Kotlin MPP shared code, a NullPointerException is guaranteed:

0   KotlinMPPClient                         0x0000000106878d2e kfun:kotlin.Throwable.<init>()kotlin.Throwable + 62
1   KotlinMPPClient                         0x000000010686b8a7 kfun:kotlin.Exception.<init>()kotlin.Exception + 55
2   KotlinMPPClient                         0x000000010686bac7 kfun:kotlin.RuntimeException.<init>()kotlin.RuntimeException + 55
3   KotlinMPPClient                         0x000000010686bce7 kfun:kotlin.NullPointerException.<init>()kotlin.NullPointerException + 55
4   KotlinMPPClient                         0x00000001068ee0e7 ThrowNullPointerException + 119
5   KotlinMPPClient                         0x00000001075dbd47 kfun:dev.icerock.moko.resources.utils.loadableBundle@platform.Foundation.NSBundle.Companion.(kotlin.String)platform.Foundation.NSBundle + 4951
6   KotlinMPPClient                         0x0000000106347302 kfun:com.romeu.project.MR.<init>$lambda-0#internal + 162
7   KotlinMPPClient                         0x0000000106347424 kfun:com.romeu.project.MR.$<init>$lambda-0$FUNCTION_REFERENCE$1.invoke#internal + 132
8   KotlinMPPClient                         0x00000001068c494c kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.getOrInit#internal + 1004
9   KotlinMPPClient                         0x00000001068c5079 kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.<get-value>()T + 393
10  KotlinMPPClient                         0x0000000106346093 kfun:com.romeu.project.MR.<get-bundle>#internal + 323
11  KotlinMPPClient                         0x0000000106346a1b kfun:com.romeu.project.MR.files.<init>()com.romeu.project.MR.files + 427
12  KotlinMPPClient                         0x0000000106c9fb55 InitSharedInstanceStrict + 197
13  KotlinMPPClient                         0x00000001064d079f kfun:com.romeu.project.utils.getResourceFileAsText(com.romeu.project.utils.ResourceMocks)kotlin.String + 1359
14  KotlinMPPClient                         0x000000010639f9e0 kfun:data.manager.Repository.$getFileStringCOROUTINE$28.invokeSuspend(kotlin.Result<kotlin.Any?>)kotlin.Any? + 24960
15  KotlinMPPClient                         0x00000001063a08ab kfun:data.manager.Repository.getFileString(kotlin.Int)kotlin.collections.List<data.models.MyChannel> + 283
16  KotlinMPPClient                         0x00000001063524eb kfun:KotlinMPPClient.$getFileString$lambda-4COROUTINE$3.invokeSuspend#internal + 1291
17  KotlinMPPClient                         0x0000000106352d7c kfun:KotlinMPPClient.$getFileString$lambda-4COROUTINE$3.invoke#internal + 268
18  KotlinMPPClient                         0x0000000106364e5a kfun:KotlinMPPClient.$executeRequest$<anonymous>_3COROUTINE$21.invokeSuspend#internal + 2730
19  KotlinMPPClient                         0x00000001068a4e88 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 712
20  KotlinMPPClient                         0x0000000106f0af66 kfun:kotlinx.coroutines.DispatchedTask.run() + 2614
21  KotlinMPPClient                         0x00000001064cba08 kfun:com.romeu.project.NsQueueDispatcher.dispatch$lambda-0#internal + 88
22  KotlinMPPClient                         0x00000001064cbafe kfun:com.romeu.project.NsQueueDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$4.invoke#internal + 62
23  KotlinMPPClient                         0x00000001064cbb5e kfun:com.romeu.project.NsQueueDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$4.$<bridge-UNN>invoke()#internal + 62
24  KotlinMPPClient                         0x00000001064cbc47 _6d656f676f73646b_knbridge22 + 183
25  libdispatch.dylib                         0x000000010f8719da _dispatch_call_block_and_release + 12
26  libdispatch.dylib                         0x000000010f872bb6 _dispatch_client_callout + 8
27  libdispatch.dylib                         0x000000010f881050 _dispatch_main_queue_callback_4CF + 1152
28  CoreFoundation                        0x000000010a9e6b8b __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
29  CoreFoundation                        0x000000010a9e16ad __CFRunLoopRun + 2111

Everything works fine on Android and in both platforms the MR stuff generation is done.

What could be causing this?

Thanks.

Edit:

It seems the NullPointerException comes from loadableBundle() extension from Moko-Resources.
But I do not know which line specifically. Could be return NSBundle.bundleWithIdentifier(identifier)!!.

I should also say that the iOS app is being ran on iOS 14.

@RomeuG
Copy link
Author

RomeuG commented Aug 3, 2020

Is this project still active?

@Alex009 Alex009 added the bug Something isn't working label Aug 4, 2020
@Alex009 Alex009 self-assigned this Aug 4, 2020
@Alex009 Alex009 added this to the 0.11.1 milestone Aug 4, 2020
@Alex009
Copy link
Member

Alex009 commented Aug 4, 2020

@RomeuG hi.
looks like bug in bundle search or bundle embeding in framework.
can you check on sample https://github.com/icerockdev/moko-resources/tree/master/sample/ios-app - this problem reproduced here on your environment? if not - please try modify sample to reproducer. or give your own reproducer project please.

@RomeuG
Copy link
Author

RomeuG commented Aug 4, 2020

@Alex009 Hey!

Thanks for responding! :-)

Sometime this week I will try your Sample. Unfortunately, I am not able to provide the reproducer project.
I will report back after testing the sample.

@RomeuG
Copy link
Author

RomeuG commented Aug 16, 2020

Sorry, other things had priority over this.

Finally I tested the samples.
They work, even on iOS 14.

It seems the problem is on my end.

Regardless, I will be trying to fix this on my project and I will report back with the solution.

@RomeuG
Copy link
Author

RomeuG commented Aug 19, 2020

@Alex009

I have made a project with the bug:

https://github.com/RomeuG/moko-resources-sample-bug

It is kinda confusing with the names and such, but I hadn't much time to prepare it.
Are you able to run it?

Edit: Should be opened with Xcode 12.0

@Alex009
Copy link
Member

Alex009 commented Aug 23, 2020

@RomeuG big thanks for demo projec! i will debug problem on next week

@RomeuG
Copy link
Author

RomeuG commented Aug 23, 2020

No problem, really. I hope it serves you well and I also hope it is more than enough for you to actually be able to solve the problem.

If you want me to change anything or have any question about the sample project, don't hesitate to ask! :-)

@Alex009
Copy link
Member

Alex009 commented Aug 27, 2020

i think problem solved here 9b02f36

maybe i do 0.11.2 release with this fix on kotlin 1.3.72

@RomeuG
Copy link
Author

RomeuG commented Aug 27, 2020

Hey!

That's great, thank you very much for the fix. I will have to try it on a 0.11.2 release... that would be awesome! :-)

EDIT: the fix for kotlin 1.3.72 is in my interest. Would you be able to do it?

@Alex009 Alex009 modified the milestones: 0.12.0, 0.11.1 Aug 27, 2020
@Alex009 Alex009 linked a pull request Aug 28, 2020 that will close this issue
Alex009 added a commit that referenced this issue Aug 28, 2020
Alex009 added a commit that referenced this issue Aug 29, 2020
@Alex009 Alex009 mentioned this issue Aug 29, 2020
@Alex009
Copy link
Member

Alex009 commented Aug 31, 2020

@RomeuG hi! are you try 0.11.1 version? it resolve your issue?

@RomeuG
Copy link
Author

RomeuG commented Aug 31, 2020

@Alex009 Hi! Yes, it did solve my issue! Thank you very much! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants