Git Product home page Git Product logo

Comments (16)

lingol avatar lingol commented on June 3, 2024

I think the crash is pretty clear. In fact it is crystal clear. MMKV is NOT initiated correctly.

What is your problem?

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

Uploading Screenshot 2024-05-13 at 10.23.01.png…
Cheers ! Sorry that I forgot to mention that I have initialize the mmkv by calling this function.

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

Uploading Screenshot 2024-05-13 at 10.26.49.png…
I'm not sure that if you could open the screenshot or not. So I upload it again and with the paste of the snippet

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    window = UIWindow(frame: UIScreen.main.bounds);
    window?.backgroundColor = UIColor.white;
    
     MMKV.initialize();

from mmkv.

lingol avatar lingol commented on June 3, 2024

I'm not buying it. Please provide the full logs of mmkv, starting from App launch.

from mmkv.

lingol avatar lingol commented on June 3, 2024

You should make MMKV.initialize() the first line of your didFinishLaunch, not the third line.

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

Cheers !
Here's the full logs.
*** Assertion failure in +[MMKV mmkvWithID:cryptKey:rootPath:mode:expectedCapacity:], libMMKV.mm:215
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'MMKV not initialized properly, must call +initializeMMKV: in main thread before calling any other MMKV methods'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804ae138 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180087db4 objc_exception_throw + 56
2 Foundation 0x0000000180d2dfd8 _userInfoForFileAndLine + 0
3 MMKV 0x0000000105f11888 +[MMKV mmkvWithID:cryptKey:rootPath:mode:expectedCapacity:] + 156
4 MMKV 0x0000000105f117e0 +[MMKV mmkvWithID:cryptKey:rootPath:mode:] + 88
5 MMKV 0x0000000105f113e8 +[MMKV mmkvWithID:mode:] + 160
6 moment 0x0000000104f5041c $sSo4MMKVC6mmapID4modeABSgSS_So8MMKVModeVtcfCTO + 64
7 moment 0x0000000104f501a4 $s6moment13OperationViewC09configSubC0yyF + 728
8 moment 0x0000000104f2ed68 $s6moment8BaseViewC5frameACSo6CGRectV_tcfc + 320
9 moment 0x0000000104f2ede8 $s6moment8BaseViewC5frameACSo6CGRectV_tcfcTo + 56
10 moment 0x0000000104f50920 $s6moment13OperationViewC5frameACSo6CGRectV_tcfc + 272
11 moment 0x0000000104f50984 $s6moment13OperationViewC5frameACSo6CGRectV_tcfcTo + 56
12 moment 0x0000000104f497a4 $s6moment13OperationViewC5frameACSo6CGRectV_tcfC + 96
13 moment 0x0000000104f4959c $s6moment9GroupCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfc + 3152
14 moment 0x0000000104f49850 $s6moment9GroupCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfcTo + 160
15 moment 0x0000000104f4c5a8 $s6moment8TextCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfc + 228
16 moment 0x0000000104f4c688 $s6moment8TextCellC5style15reuseIdentifierACSo011UITableViewC5StyleV_SSSgtcfcTo + 160
17 UIKitCore 0x0000000185603c04 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 416
18 UIKitCore 0x0000000185603e44 -[UITableView dequeueReusableCellWithIdentifier:] + 152
19 UIKitCore 0x0000000185604034 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 216
20 UIKitCore 0x0000000185603f38 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 68
21 moment 0x0000000104f2d644 $s6moment16MomentControllerC9tableView_12cellForRowAtSo07UITableE4CellCSo0jE0C_10Foundation9IndexPathVtF + 612
22 moment 0x0000000104f2d7dc $s6moment16MomentControllerC9tableView_12cellForRowAtSo07UITableE4CellCSo0jE0C_10Foundation9IndexPathVtFTo + 136
23 UIKitCore 0x0000000185618c8c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1376
24 UIKitCore 0x00000001855eba54 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 560
25 UIKitCore 0x00000001855ec06c -[UITableView _updateVisibleCellsNow:] + 1112
26 UIKitCore 0x0000000185606168 -[UITableView layoutSubviews] + 144
27 UIKitCore 0x000000018590a128 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1492
28 QuartzCore 0x000000018a1ae654 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 440
29 QuartzCore 0x000000018a1b940c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 124
30 QuartzCore 0x000000018a0f2d30 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 460
31 QuartzCore 0x000000018a122aa8 _ZN2CA11Transaction6commitEv + 652
32 UIKitCore 0x0000000185400570 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
33 CoreFoundation 0x000000018040ec50 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 20
34 CoreFoundation 0x000000018040e398 __CFRunLoopDoBlocks + 352
35 CoreFoundation 0x0000000180408c3c __CFRunLoopRun + 788
36 CoreFoundation 0x0000000180408514 CFRunLoopRunSpecific + 572
37 GraphicsServices 0x000000018ef06ae4 GSEventRunModal + 160
38 UIKitCore 0x00000001853e8040 -[UIApplication _run] + 868
39 UIKitCore 0x00000001853ebcc8 UIApplicationMain + 124
40 moment 0x0000000104f4671c main + 64
41 dyld 0x000000010515d544 start_sim + 20
42 ??? 0x00000001052020e0 0x0 + 4380958944
43 ??? 0x3401800000000000 0x0 + 3747417102437318656
)
libc++abi: terminating due to uncaught exception of type NSException

Now I have changed the position of the MMKV.initialize(). The issue remains the same.

from mmkv.

lingol avatar lingol commented on June 3, 2024

No, that is the crash stack. I'm taking about logs from console.

from mmkv.

lingol avatar lingol commented on June 3, 2024

To be clear, add a line of log before you call MMKV.initialize(). And if there's no log, then mmkv is not initiated.

from mmkv.

lingol avatar lingol commented on June 3, 2024

And if that's the case, move it to your main() function or create a constructor function for your AppDelegate.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    init() {
        MMKV.initialize()

        super.init()
    }
……
}

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

I have added the lines at the beginning of the code.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

override init(){
    print(Thread.current)
    
    MMKV.initialize()
    
    super.init()
}


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    
    
    // Override point for customization after application launch.
    window = UIWindow(frame: UIScreen.main.bounds);
    window?.backgroundColor = UIColor.white;

Here is my backtrace

  • thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x0000000105ec49ec libsystem_kernel.dylib__pthread_kill + 8 frame #1: 0x0000000104e6f1d0 libsystem_pthread.dylibpthread_kill + 256
    frame #2: 0x00000001801655c0 libsystem_c.dylibabort + 104 frame #3: 0x00000001802a7798 libc++abi.dylibabort_message + 128
    frame #4: 0x0000000180298eec libc++abi.dylibdemangling_terminate_handler() + 300 frame #5: 0x0000000180063498 libobjc.A.dylib_objc_terminate() + 124
    frame #6: 0x00000001802a6c70 libc++abi.dylibstd::__terminate(void (*)()) + 12 frame #7: 0x00000001802a9acc libc++abi.dylib__cxa_rethrow + 144
    frame #8: 0x0000000180087f48 libobjc.A.dylibobjc_exception_rethrow + 40 frame #9: 0x00000001804085c4 CoreFoundationCFRunLoopRunSpecific + 748
    frame #10: 0x000000018ef06ae4 GraphicsServicesGSEventRunModal + 160 frame #11: 0x00000001853e8040 UIKitCore-[UIApplication _run] + 868
    frame #12: 0x00000001853ebcc8 UIKitCore`UIApplicationMain + 124
    • frame #13: 0x0000000104c92724 momentmain at AppDelegate.swift:13:7 frame #14: 0x0000000105439544 dyld_simstart_sim + 20
      frame #15: 0x0000000104f360e0 dyld`start + 2360

Also, I have upgraded the UIKit to the latest version. This issue is still unfixed.

from mmkv.

lingol avatar lingol commented on June 3, 2024

What are the logs from the console?
Is it so hard to understand?

from mmkv.

lingol avatar lingol commented on June 3, 2024

You know what, I'm tired of repeating to ask the same question. Why don't you upload a reproducible demo?

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

Sorry for causing you any trouble. I'm still learning as a beginner. Here is the repository of the project:https://github.com/EchoHayate/Moment

from mmkv.

lingol avatar lingol commented on June 3, 2024

The problem is that you have called the wrong initialize method.

// MMKV.initialize();
MMKV.initialize(rootDir: nil);

Change it as the code above and you should have no problem.

The initialize() method is inherited from NSObject and is useless. I should make it hidden later.

from mmkv.

EchoHayate avatar EchoHayate commented on June 3, 2024

Cheers! I think I couldn't find the log from console even though I tried many times across the Internet. Could you please tell me how to do it? Many Thanks!

from mmkv.

lingol avatar lingol commented on June 3, 2024

https://stackoverflow.com/questions/483493/how-to-show-the-logged-messages-window-in-xcode

from mmkv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.