How is this error possible: Unrecognized Selected (screenFontWithRenderingMode) in iOS? - ios

This one doesn't make any sense to me. My app crashes with the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x209bb200'
This is an iOS app. From what I can see, screenFontWithRenderingMode is an NSFont method for Mac OS X, not iOS. So how can this error even be occurring?
I am building the app with the newly released Xcode 5. The app will support iOS version 6.1 and 7.0 (and higher). This error ONLY occurs when running the app on a 6.1 device (and simulator).
EDIT:
I wasn't able to produce the crash log by running the app in debug mode. By creating an Ad Hoc build I was able to load the app, run it, crash, and retrieve the crash log:
0 CoreFoundation 0x3220a29e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x3a06e97a objc_exception_throw + 26
2 CoreFoundation 0x3220de02 -[NSObject(NSObject) doesNotRecognizeSelector:] + 166
3 CoreFoundation 0x3220c52c ___forwarding___ + 388
4 CoreFoundation 0x32163f64 __forwarding_prep_0___ + 20
5 UIFoundation 0x37da15c8 +[NSStringDrawingTextStorage _fastDrawString:attributes:length:inRect:graphicsContext:baselineRendering:usesFontLeading:usesScreenFont:typesetterBehavior:paragraphStyle:lineBreakMode:boundingRect:padding:scrollable:baselineOffset:] + 344
6 UIFoundation 0x37da0184 -[NSAttributedString(NSExtendedStringDrawing) _doBoundingRectWithSize:options:context:baselineOffset:] + 676
7 UIFoundation 0x37d9fc8c -[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] + 2492
I was able to track down the offending line:
CGRect rect = [[MLFeedCell attributedBodyForItem:item].attributedString boundingRectWithSize:CGSizeMake(labelWidth, 10000) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
I'm not sure what's wrong with this call.

The error is because you are trying to use:
[NSString boundingRectWithSize:options:attributes:context:]
That method was added in IOS 7.0 in the NSStringDrawing.h category.
source:
IOS7 API Diffs

Related

How to debug React Native error with no error stack

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

Plugin should use a background thread ( Terminating app due to uncaught exception 'NSInvalidArgumentException' )

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.

App crash when using test flight

Finally I finish my application so it is time to make some beta test. So I upload my application to itunes connect to test it out with test flight, but it keep crashing when I perform few task.
When I try to open the app from downloaded menu in test flight app.
When I try make a http request with AFnetworking
When I insert new record to CoreData
Sometime when i open the app from test flight it did not crash but show me a black screen after lauch screen.
I have been searching for 5 day without any clue. I been test it out with both release and debug mode running from xcode it doesn't crash at all. The problem only occur on if the app install from testflight. I think might be some memory allocated issues. It is a bug from testflight? How can I make the same behaviour happening at test flight happen in my xcode as well to know and fix the error.
I'm targeting ios 8.0 ++
Testing on iphone 7 plus(ios 10.2) and iphone 5s(ios 9.3).
Xcode 8.3.2
I get alot of difference crash report but most of it similiar to this one. Maybe I insert some nil value into dictionary? But why does it not happen when I build it from xcode.
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Filtered syslog:
None found
Last Exception Backtrace:
0 CoreFoundation 0x18319ee38 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x182803f80 objc_exception_throw + 56
2 CoreFoundation 0x183084554 -[__NSDictionaryM setObject:forKey:] + 924
3 Cellecter 0x1001db19c 0x100040000 + 1683868
4 Cellecter 0x1001dafe4 0x100040000 + 1683428
5 CoreFoundation 0x183140eac __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
6 CoreFoundation 0x1831406cc _CFXRegistrationPost + 396
7 CoreFoundation 0x18314044c ___CFXNotificationPost_block_invoke + 60
8 CoreFoundation 0x1831a9494 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1532
9 CoreFoundation 0x18307e788 _CFXNotificationPost + 368
10 Foundation 0x183adfd1c postQueueNotifications + 684
11 CoreFoundation 0x1831547b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
12 CoreFoundation 0x183152554 __CFRunLoopDoObservers + 372
13 CoreFoundation 0x183152884 __CFRunLoopRun + 672
14 CoreFoundation 0x18307cd10 CFRunLoopRunSpecific + 384
15 GraphicsServices 0x184964088 GSEventRunModal + 180
16 UIKit 0x188351f70 UIApplicationMain + 204
17 Cellecter 0x1001e8834 0x100040000 + 1738804
18 libdyld.dylib 0x182c1a8b8 start + 4
Updated: some how the my first and fourth question have been fix Now my question narrow it down to crashing when try to insert record into afnetworking.
This could be a lot of things.
It can be a migration issue with CoreData, a ManagedObjectContext issue.
The blackscreen could be a view issue.
Your question is too broad, we don't have code, we don't know your recent development.
Are you using real devices ? Emulators ? Which version of Xcode ? iOS deployment target ?
Please refer to this post next time you ask a question.
How to Ask
I finally manage to fix the issues. Actually the issues is quite simple, I will not be able to fix the issues if I don't symbolicate my crash report, actually the issues is on FCM, From here specifically say I need a production push certificate in order to receive the device token. Which the device token return nil every time and I attempt save the token to core data.

Firebase initWitURL crashes [FRepo initTransactions]: unrecognized selector

I have set up two similar firebase applications.
In both cases I call
self.firebase = [[Firebase alloc] initWithUrl:kFirebaseRoot];
in one case everything works fine.
In the other case I get a crash
2014-05-19 11:18:59.726 MyApp[28041:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FRepo initTransactions]: unrecognized selector sent to instance 0x8f50c10'
First throw call stack:*
0 CoreFoundation 0x023131e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x020928e5 objc_exception_throw + 44
2 CoreFoundation 0x023b0243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0230350b ___forwarding___ + 1019
4 CoreFoundation 0x023030ee _CF_forwarding_prep_0 + 14
5 MyApp 0x0002b63b -[FRepo initWithRepoInfo:] + 187
6 MyApp 0x0002ab05 -[FRepoManager getLocalRepo:] + 597
7 MyApp 0x0002b3ff +[FRepoManager getRepo:] + 111
8 MyApp 0x000544dc -[Firebase initWithUrl:] + 204
9 MyApp 0x000172f2 -[FLPresenceManager initFirebase] + 194
This appears to be something going on within Firebase, so I presume there must be something different in the way I have set up the app in the two cases. However, I cannot see a difference.
Can anyone offer any clues?
This answer was posted in the comments of the question.
The problem seems to be having -objC instead of -ObjC in the linker flags.
Just for completion sake for the next person, this is exactly where it can be found:

_NSInlineData base64EncodedString - unrecognized selector sent to instance

I created an ipad project in XCode based on the Evernote SDK sample. The method for testing OAuth worked. I switched from direct sources in project to CocoaPods pod 'Evernote-SDK-iOS', '~> 1.3' and now I'm getting following exception.
When it stopped working I noticed that I was running the simulator for "iPad" unintentionally. I used "iPad Retina 64bit" before when it worked in the beginning. When I switched to 64bit it worked. I tried it in the version with direct sources instead of pods and for "iPad" version it opened Authorizing popup, when I logged in I was able to log in for "iPad" in the CocoaPods version too.... seems that in the CocoaPods version there is a problem with the authorization and not in the difference between simulators... it just works when I first authorize my app using my old code...
Any idea where could be a difference between direct source code in project and using CocoaPods?
I get the exception on row 153: return [data base64EncodedString]; in file ENGCOAuth.m
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSInlineData base64EncodedString]: unrecognized selector sent to instance 0x958ca10'
*** First throw call stack:
(
0 CoreFoundation 0x01b001e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x009538e5 objc_exception_throw + 44
2 CoreFoundation 0x01b9d243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01af050b ___forwarding___ + 1019
4 CoreFoundation 0x01af00ee _CF_forwarding_prep_0 + 14
5 MemloNotepad 0x001d378a -[ENGCOAuth signature] + 618
6 MemloNotepad 0x001d3187 -[ENGCOAuth authorizationHeader] + 167
7 MemloNotepad 0x001d2fb5 -[ENGCOAuth request] + 245
8 MemloNotepad 0x001d4dba +[ENGCOAuth URLRequestForPath:GETParameters:scheme:host:consumerKey:consumerSecret:accessToken:tokenSecret:] + 1082
9 MemloNotepad 0x001eb38c -[EvernoteSession startOauthAuthentication] + 348
10 MemloNotepad 0x001ead7e __68-[EvernoteSession authenticateWithViewController:completionHandler:]_block_invoke + 558
11 MemloNotepad 0x001cfec7 __44-[ENAPI invokeAsyncIdBlock:success:failure:]_block_invoke_2 + 55
Note: I already asked this question in Evernote forum but I didn't get any reply for almost one month.
Another StackOverflow question helped me to solve the problem.
I had to add $(inherited) in Other Linker Flags in Build Settings. I had it in one of the targets but not in all of them.

Resources