I am new to Xcode and Objective-C. Unlike Android Java exceptions, I didn't find any exact line number where the exception occurred, though function name can be known from the crash log. Following is the crash log:
2014-07-28 17:44:53.814 ExampleApp[82720:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x034b25e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x028bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x03464bcc -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x03464870 -[__NSArrayM addObject:] + 64
4 ExampleApp 0x0017f99e +[ReportGenerator prepareReportList:] + 5486
5 ExampleApp 0x0017db99 +[ReportGenerator generateReportContent:viewController:] + 73
6 ExampleApp 0x0017b682 +[ReportGenerator generateReport:viewController:style:] + 322
7 ExampleApp 0x000a68fd -[ReportsViewController showReport] + 189
8 libobjc.A.dylib 0x028ce81f -[NSObject performSelector:withObject:] + 70
9 Foundation 0x01fa29d8 __NSThreadPerformPerform + 285
10 CoreFoundation 0x0343b83f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
11 CoreFoundation 0x0343b1cb __CFRunLoopDoSources0 + 235
12 CoreFoundation 0x0345829e __CFRunLoopRun + 910
13 CoreFoundation 0x03457ac3 CFRunLoopRunSpecific + 467
14 CoreFoundation 0x034578db CFRunLoopRunInMode + 123
15 GraphicsServices 0x046949e2 GSEventRunModal + 192
16 GraphicsServices 0x04694809 GSEventRun + 104
17 UIKit 0x010bbd3b UIApplicationMain + 1225
18 ExampleApp 0x0011679d main + 125
19 libdyld.dylib 0x0300a701 start + 1)libc++abi.dylib: terminating with uncaught exception of type NSException
You can add a breakpoint to stop on all exceptions.
From Apple Docs
In the bottom-left corner of the breakpoints navigator, click the Add button.
Choose Add Exception Breakpoint.
In the Exception pop-up menu, choose the type of exception on which you want execution to stop:
All. Stops on all exceptions.
Objective-C. Stops on Objective-C exceptions.
C++. Stops on C++ exceptions.
To stop on a particular C++ exception, specify the exception name.
Choose the phase of the exception handling process at which you want program execution to stop.
Click Done.
The crash is happening in your +[ReportGenerator prepareReportList:] method. Specifically, when attempting to add an object to an array.
Only, the object is nil. Which is why the log starts with object cannot be nil.
(Note: As you come from the world of Java exceptions, don't make the mistake of thinking that ObjC exceptions are designed to be caught and recovered from. They aren't.)
Related
Since I upgraded to Xcode 12 my release builds are crashing on iOS for both the simulator and on devices. The problem is that there is no error stack and the error is not giving me a hint where to start. When running in debug there are no errors shown.
I assume there is some version mismatch for a dependency or an issue with the js bundling.
Did anyone encounter the same error or knows how to debug release builds? I would highly appreciate help.
Running application <REDACTED> ({
initialProps = {
};
rootTag = 1;
})
2020-11-25 18:38:00.767418+0100 EASY[37489:403160] [native] Unhandled JS Exception: Maximum call stack size exceeded.
no stack
2020-11-25 18:38:00.771458+0100 EASY[37489:403160] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Maximum call stack size exceeded.
no stack', reason: 'Unhandled JS Exception: Maximum call stack size exceeded.
no stack'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b2dbaf2 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x000000010b130e78 objc_exception_throw + 48
2 EASY 0x00000001044d0182 RCTFormatError + 0
3 EASY 0x00000001044e7267 __28-[RCTCxxBridge handleError:]_block_invoke + 677
4 libdispatch.dylib 0x000000010f0e27ec _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x000000010f0e39c8 _dispatch_client_callout + 8
6 libdispatch.dylib 0x000000010f0f1e75 _dispatch_main_queue_callback_4CF + 1152
7 CoreFoundation 0x000000010b249dab __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
8 CoreFoundation 0x000000010b24462e __CFRunLoopRun + 2685
9 CoreFoundation 0x000000010b2436c6 CFRunLoopRunSpecific + 567
10 GraphicsServices 0x00000001106e2db3 GSEventRunModal + 139
11 UIKitCore 0x0000000119b3a187 -[UIApplication _run] + 912
12 UIKitCore 0x0000000119b3f038 UIApplicationMain + 101
13 EASY 0x000000010433a436 main + 80
14 libdyld.dylib 0x000000010f172409 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Maximum call stack size exceeded.
no stack', reason: 'Unhandled JS Exception: Maximum call stack size exceeded.
no stack'
terminating with uncaught exception of type NSException
CoreSimulator 732.18.0.2 - Device: iPhone 11 (F7A041B8-8C3F-4F6C-86FA-D11C8F1B5571) - Runtime: iOS 14.2 (18B79)
I am on Xcode 12.2 with RN 0.63.3
i am trying to use cordova keychain [plugin][1] for ios, inside my ionic application. but facing this error
6:48 PM2020-07-14 18:44:32.456726+0500 Farsh[1817:53270] THREAD
WARNING: ['Keychain'] took '14.635986' ms. Plugin should use a
background thread. 2020-07-14 18:44:32.456767+0500 Farsh[1817:55957]
-[NSNull boolValue]: unrecognized selector sent to instance 0x7fff8062d9d0 2020-07-14 18:44:32.614153+0500 Farsh[1817:55957] ***
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[NSNull boolValue]:
unrecognized selector sent to instance 0x7fff8062d9d0'
*** First throw call stack: ( 0 CoreFoundation 0x00007fff23e3cf0e __exceptionPreprocess + 350 1 libobjc.A.dylib 0x00007fff50ba89b2 objc_exception_throw + 48 2 CoreFoundation 0x00007fff23e5dc34
-[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fff23e4190c forwarding + 1436 4 CoreFoundation
0x00007fff23e43bf8 _CF_forwarding_prep_0 + 120 5 Farsh
0x000000010e66aac0 __19-[CDVKeychain set:]_block_invoke + 432 6
libdispatch.dylib 0x000000010e9c7f11 _dispatch_call_block_and_release
12 7 libdispatch.dylib 0x000000010e9c8e8e _dispatch_client_callout + 8 8 libdispatch.dylib 0x000000010e9cb2d8
_dispatch_queue_override_invoke + 1022 9 libdispatch.dylib 0x000000010e9da399 _dispatch_root_queue_drain + 351 10
libdispatch.dylib 0x000000010e9daca6 _dispatch_worker_thread2 + 135 11
libsystem_pthread.dylib 0x00007fff51c089f7 _pthread_wqthread + 220 12
libsystem_pthread.dylib 0x00007fff51c07b77 start_wqthread + 15 )
libc++abi.dylib: terminating with uncaught exception of type
NSException (lldb)
and my application crashed after this. Is there anyone know how to solve this problem ??
Please answer
Thanks in advance.
[1]: https://ionicframework.com/docs/native/keychain
Solution
I had the same problem and the issue was that I didn't explicitly set a value for the useTouchId parameter. This bug is known since 2018 and still not fixed. Shows you how good ionic is as an ecosystem and how much the people care 😤 Worse is that even the official docs(!) have an incorrect example:
Wrong
this.keychain.set(key, value).then(() => { ... }
Correct
this.keychain.set(key, value, false).then(() => { ... }
Adding the third parameter should fix your issues.
I've followed the iOS sdk guide on facebook. But when I click on the login with facebook icon, and im getting the page up. But when I click "Continue" on facebook the app closes and I get kicked out from it.
019-03-18 22:39:46.552355+0100 APPNAME[75124:2466803]
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:' -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]'
First throw call stack:
(
0 CoreFoundation 0x0000000111c2b1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010fdf5735 objc_exception_throw + 48
2 CoreFoundation 0x0000000111b774ec _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000111c9a541 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
4 CoreFoundation 0x0000000111c26c9b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
5 APPNAME 0x000000010e481d90 -[ViewController Callfb_LoginService:] + 576
6 APPNAME 0x000000010e480a3f __33-[ViewController GetFBUserDetail]_block_invoke + 1999
7 APPNAME 0x000000010e6d2d20 -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] + 146
8 APPNAME 0x000000010e6d9532 __82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke396 + 141
9 APPNAME 0x000000010e6d92d6 -[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:] + 1065
This is just a part of the error log.
Would appreciate it if anyone could help me out here!
Thanks
I am writing an iOS app, using Swift.
The app crashes some time and what I get in the console is this:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: updated_objectIDs)'
*** First throw call stack:
(0x1858151b8 0x18424c55c 0x1856f5a0c 0x1856ffa40 0x187bc3540 0x187b4edf8 0x187b399bc 0x187b329dc 0x1857c20c0 0x1857bfcf0 0x1857c0180 0x1856ee2b8 0x1871a2198 0x18b7357fc 0x18b730534 0x100069440 0x1846d15b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I am trying to figure out where this is coming from.
I have no idea at the moment what parts of my code could cause this crash.
What is the proper way to find more information and possibly find the part in code that is causing this crash?
You can create a new Exception breakpoint.This will help you find out line number where the exception is occurring in Xcode.
Check below link for more details.
Xcode doesn't show the line that causes a crash
Objective C - getting line number or full stack trace from debugger error?
So, I have tried the suggested approaches. No luck yet.
Maybe adding the rest of the log can help people getting more information and maybe help me figure out what is going on. This is what I see in the console when the app crashes:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: updated_objectIDs)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010de39d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010d2f521e objc_exception_throw + 48
2 CoreFoundation 0x000000010dd4fd87 -[__NSDictionaryM setObject:forKey:] + 1047
3 CoreFoundation 0x000000010ddb8729 -[NSMutableDictionary addEntriesFromDictionary:] + 329
4 CoreData 0x000000010da00b14 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1844
5 CoreData 0x000000010d9646f7 -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 215
6 CoreData 0x000000010d962dbf -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 111
7 CoreData 0x000000010d93c143 _performRunLoopAction + 339
8 CoreFoundation 0x000000010ddde267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
9 CoreFoundation 0x000000010ddde1d7 __CFRunLoopDoObservers + 391
10 CoreFoundation 0x000000010ddc2f8e __CFRunLoopRun + 1198
11 CoreFoundation 0x000000010ddc2884 CFRunLoopRunSpecific + 420
12 GraphicsServices 0x000000011234fa6f GSEventRunModal + 161
13 UIKit 0x000000010f060c68 UIApplicationMain + 159
14 App 0x000000010adae2ff main + 111
15 libdyld.dylib 0x00000001113a768d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
in the exception I'm seeing: setObjectForKey and a key of updated_objectIDs.
There's a couple things I would do to track this down. First thing I might try would be to search for updated_objectIDs and see where it might be getting passed into setObjectForKey.
Then log the address (or description) of the object being passed in at that point and you might catch it as it's happening.
Even better (and what I do in my own work) is to set a breakpoint on all exceptions. You can do it by following the steps in this answer in this closely related question.
Then, when the exception fires, Xcode will stop at that line of code.
I originally downloaded the FBSDK's version 4.10 and integrated them into my application by placing them in the frameworks folder. Realizing that these would not get updated over time, I removed them completely and tried to add them as pods to my project. The pods installed successfully, I have imported them correctly in my bridging header file, and there were no other issues. The pods update installed version 4.11 which has caused me some headache.
I am using the FBSDKLoginKit to log a user into their account and retrieve information from that. I am able to get back a dictionary with the users information just fine. I then pass this information to the next ViewController with a segue. At any point after this, if I press the home button on my iPhone or simulator, the app will crash. The error I get is
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[3]'
This exception also occurs if I let the user log in through facebook, segue to the new view controller, unwind to the previous view controller, and then attempt to log in again. I have attempted to log the user out once retrieving their pertinent information on the second screen, but the error still persists.
I have seen a similar question asked where the "solution" was that the FBSDKLoginKit writes the retrieved dictionary to a variable and if the dictionary it has retrieved back has nil values, it throws this error.
Is there anything I can do to catch this before it happens? Has anyone found a work around?
Here is my output from the simulator when I press home:
*** First throw call stack:
(
0 CoreFoundation 0x0000000106f03d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010643edeb objc_exception_throw + 48
2 CoreFoundation 0x0000000106e0023e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
3 CoreFoundation 0x0000000106e125bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4 APPNAME 0x0000000101607a1e -[FBSDKTimeSpentData instanceSuspend] + 622
5 APPNAME 0x000000010160766b +[FBSDKTimeSpentData suspend] + 59
6 APPNAME 0x00000001015b5986 -[FBSDKAppEvents applicationMovingFromActiveStateOrTerminating] + 262
7 CoreFoundation 0x0000000106ecdc8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x0000000106ecd9cb _CFXRegistrationPost + 427
9 CoreFoundation 0x0000000106ecd732 ___CFXNotificationPost_block_invoke + 50
10 CoreFoundation 0x0000000106f161e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
11 CoreFoundation 0x0000000106dc5679 _CFXNotificationPost + 633
12 Foundation 0x000000010372ccd9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
13 UIKit 0x0000000104a685ad -[UIApplication _deactivateForReason:notify:] + 629
14 UIKit 0x0000000104a6f1f1 __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 104
15 FrontBoardServices 0x0000000108f88d6c __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke27 + 213
16 Foundation 0x000000010377d5bb __NSIndexSetEnumerate + 1016
17 BaseBoard 0x000000010901ba8c -[BSSettingsDiff inspectChangesWithBlock:] + 116
18 FrontBoardServices 0x0000000108f83e4a -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 92
19 FrontBoardServices 0x0000000108f88b2f -[FBSSettingsDiffInspector inspectDiff:withContext:] + 317
20 UIKit 0x0000000104a70880 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 127
21 UIKit 0x0000000104a7052d -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 843
22 FrontBoardServices 0x0000000108f978c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
23 FrontBoardServices 0x0000000108f97741 -[FBSSerialQueue _performNext] + 178
24 FrontBoardServices 0x0000000108f97aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
25 CoreFoundation 0x0000000106e29301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26 CoreFoundation 0x0000000106e1f22c __CFRunLoopDoSources0 + 556
27 CoreFoundation 0x0000000106e1e6e3 __CFRunLoopRun + 867
28 CoreFoundation 0x0000000106e1e0f8 CFRunLoopRunSpecific + 488
29 GraphicsServices 0x0000000108ae7ad2 GSEventRunModal + 161
30 UIKit 0x0000000104a72f09 UIApplicationMain + 171
31 APPNAME 0x00000001013a26d2 main + 114
32 libdyld.dylib 0x0000000107b0d92d start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Running my code step by step I find that the error occurs during the method:
fbLoginManager.logInWithReadPermissions(permissionsNeeded, fromViewController: self) { (result, error) -> Void in
//crashes before it enters this block
//my code here
}
It crashes before I can even check the error value. I will attempt to check the values by stepping into the fbsdk methods and update
As soon as I press OK on this screen for the second time it crashes. How can I debug this? The action isn't in my app, its in the browser so I'm not sure where to go from here..
I have came across this issues recently, and i solved it by adding this piece of code in Appdelegate.m.
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
For Swift 3 version:
func applicationDidBecomeActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
Update to 4.12, it fixes the issue according to their release notes:
https://developers.facebook.com/docs/ios/change-log-4.x/
The part that says:
Fixed
Fixed cases where AppEvents could crash because of missing session id.
Fixed bug in some cases where access token expiration date was the refresh date.
Although this is not necessarily a comprehensive solution, I have exhausted my debugging methods. I have removed the FBSDK's from my podfile, run pod update to remove them from the project, and reinstalled the version 4.10 FBSDK's in my frameworks folder. I will update this question after trying again when facebook releases an updated version of the FBSDK's.