Unrecognized selector on calling Google Toolbox for Mac NSString category method in iOS - iphone

I'm building a static library for use in an iOS project, and I want to decode XML entities returned from a web service. I've grabbed Google Toolbox for Mac and added the following files to my project:
GTMDefines.h
GTMNSString+HTML.h
GTMNSString+HTML.m
Then in my own .m file I'm doing this:
#import "GTMNSString+HTML.h"
// then in one of my methods:
NSString *value = [anotherNSStringValue gtm_stringByUnescapingFromHTML];
The code compiles fine, but when I run the app that uses my static library it crashes with a NSInvalidArgumentException, complaining that the gtm_stringByUnescapingFromHTML selector isn't recognised for NSString:
2011-02-10 12:21:38.401 MyApp[20356:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString gtm_stringByUnescapingFromHTML]: unrecognized selector sent to instance 0x71403e0'
*** Call stack at first throw:
(
0 CoreFoundation 0x0111bbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012705c2 objc_exception_throw + 47
2 CoreFoundation 0x0111d6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0108d366 ___forwarding___ + 966
4 CoreFoundation 0x0108cf22 _CF_forwarding_prep_0 + 50
5 MyApp 0x00028dcf -[GSMyAppXMLParser parseData:] + 714
// Rest of stack trace removed
)
terminate called after throwing an instance of 'NSException'
I've found a few similar issues on Stack Overflow, and in each case the questioner has subsequently commented that they fixed it by tweaking a linker setting - but without disclosing which setting! If anyone can help me with this I'd be forever grateful!

I’m guessing that would be the -ObjC and -all_load flags.
You add these to the ‘Other Linker Flags’ of the app that links agains the library, not the library itself.
For more info see: http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html

Related

Gigya is crashing during initialization in Swift project

Does anyone tried to use Gigya with swift?
I've linked Gigya's framework to project, created bridging file and #import there < GigyaSDK/Gigya.h >. While I'm trying init Gigya - I receive exception
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString GSGUIDString]: unrecognized selector sent to class 0x10a6bbb20'
*** First throw call stack:
(
0 CoreFoundation 0x0000000109e7fe65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c148deb objc_exception_throw + 48
2 CoreFoundation 0x0000000109e8838d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000109dd590a ___forwarding___ + 970
4 CoreFoundation 0x0000000109dd54b8 _CF_forwarding_prep_0 + 120
5 Application 0x00000001094f6063 -[GSRequest initWithSession:method:parameters:useHTTPS:requestTimeout:] + 515
6 Application 0x00000001094f6251 -[GSRequest initWithSession:method:] + 241
7 Application 0x00000001094f5ce3 +[GSRequest requestForMethod:] + 131
8 Application 0x00000001094fd83b -[Gigya getSDKConfig] + 59
9 Application 0x00000001094fc596 +[Gigya initWithAPIKey:application:launchOptions:APIDomain:] + 790
As I checked, this class is Int.
Does anyone know how to solve this problem? Variant with "cut this piece of… Single Sign-On service" doesn't acceptable ;)
Set Linker Flags to -ObjC in Build Settings.
If you want to use Gigya in the Swift project - you must use not Gigya's framework but Gigya's source (You can find both of them here). Just add it to your project and create bridging file, where you should add #import "Gigya.h"

TGAccessoryManager causes argument exception on fireDataReceived

I've been trying to research this error for a while, but to no avail. Every time it looks like TGAccessoryManager should be sending my application data, an argument exception occurs:
2013-04-30 11:46:01.905 mindyieldapp[14537:907] Exception: *** -[NSDictionary initWithDictionary:copyItems:]: dictionary argument is not an NSDictionary
2013-04-30 11:46:01.918 mindyieldapp[14537:907] Stack trace: (
0 CoreFoundation 0x33d7f2bb <redacted> + 186
1 libobjc.A.dylib 0x3ba2497f objc_exception_throw + 30
2 CoreFoundation 0x33d0bff5 <redacted> + 212
3 mindyieldapp 0x000c1539 -[TGAccessoryManager fireDataReceived:] + 336
I'm certain my code is wired up correctly, as I've stripped it down significantly, and the accessoryDidConnect/accessoryDidDisconnect selectors are being called. I'm targeting iOS 6.1, with the latest version of the Neurosky SDK (I just re-downloaded to be sure). Any assistance is appreciated.
The error is quite clear, copyItems is not an instance of NSDicitonary. Put a breakpoint on
the line with [NSDictionary initWithDictionary:copyItems:] and see of what type is copyItems instance of.

CrashReport from Hockey, awkward Stacktrace with NSPlaceholderDictionary

got some strange stack trace from an app i developed. here the stack trace:
Exception Type: SIGTRAP
Exception Codes: #0 at 0x312b1848
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[0]'
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x35c48848 __kill + 8
1 CoreFoundation 0x34dba957 __handleUncaughtException + 75
2 libobjc.A.dylib 0x361e1345 _objc_terminate + 129
3 libc++abi.dylib 0x000043c5 safe_handler_caller(void (*)()) + 77
4 libc++abi.dylib 0x00004451 operator delete(void*) + 1
5 libc++abi.dylib 0x00005825 __cxa_current_exception_type + 1
6 libobjc.A.dylib 0x361e12a9 objc_exception_rethrow + 13
7 CoreFoundation 0x34d1050d CFRunLoopRunSpecific + 405
8 CoreFoundation 0x34d1036d CFRunLoopRunInMode + 105
9 GraphicsServices 0x36f85439 GSEventRunModal + 137
10 UIKit 0x32df5cd5 UIApplicationMain + 1081
11 myApp 0x000073f9 main (main.m:42)
this happens when you click on a tableview and a view should be pushed on the navigation controller. i never get this bug reproduced, so i could not say precisely, when it happened.
it could be that only iOS 5.1.1 is affected (only crash reports from this version exists).
i always check objects before adding them to a dict, so could loading xibs be a reason for that? perhaps it is kind of damaged, i recognized that sometimes xibs are in a very strange way...
thanks for every help
If your crash reporter isn't reporting the exception backtrace, it needs to be fixed. Exceptions on the main thread have been caught and "re-thrown" (hence objc_exception_rethrow) since iOS 5 (nearly a year ago!).
I think __NSPlaceholderDictionary is just what you get by calling [NSDictionary alloc]. I suspect the culprit is code that does [NSDictionary dictionaryWithObject:x forKey:#"foo"] without checking that x is non-nil.
iTunes Connect's crash reporting may also be helpful, though they display a very small subset of actual crashes.

How to read Xcode console output?

As a Java and PHP developer new to Xcode, I am having trouble dealing with memory errors. I have a sample program from a book, which crashes on startup with "Program received signal 'SIGABRT'." I don't know what to do with the console output below. I realize it's some kind of stack trace, but the name on the left is just the name of the application, not a class or file. I don't know what "main + 121" or "start + 53" means or where to look. Any guidance would be appreciated.
2011-05-11 10:43:23.071 FlowerInfoNavigator[22537:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary objectForKey:]: method sent to an uninitialized mutable dictionary object'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00dbf542 -[__NSPlaceholderDictionary objectForKey:] + 194
3 FlowerInfoNavigator 0x0000289a -[RootViewController tableView:didSelectRowAtIndexPath:] + 330
4 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
5 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
6 Foundation 0x0079b79e __NSFireDelayedPerform + 441
7 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
9 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
10 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
11 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
12 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
13 GraphicsServices 0x00ffa289 GSEventRun + 115
14 UIKit 0x00022c93 UIApplicationMain + 1160
15 FlowerInfoNavigator 0x00001b99 main + 121
16 FlowerInfoNavigator 0x00001b15 start + 53
)
terminate called after throwing an instance of 'NSException'
(gdb)
On the right are the methods that were called that are on the stack. I generally just look for anything that is from one of my methods (though this won't always work) and then it'll give you the method call that the problem originated from. in the trace at call number 3 on "FlowerInfoNavigator" the method tableView:didSelectRowAtIndexPath: was called and somewhere in there is what caused the crash. You should be able to use the debugger and breakpoints to narrow it down from there hopefully. Good luck.
Edit: as I relooked at your error message: at the top of it it gives you the error. You tried to retrieve an object from a NSDictionary that wasn't initialized yet, and from above, it occurred in your didSelectRowAtIndexPath method
The console wouldn't be the only place you look. Take a look at your Debugger too. Over there there is usually one line that is bolded. If you tap that it'll show you exactly where the crash happened.
Looks like you didn't init your NSDictionary
The Crash is due to nsdictionary is not initialized yet and how to search for during a crash ,first look at console so you will get idea about what caused the crash or exception and to get where the application crashed you can check out debugger .In the debugger the the particlar line will be in bold where the application crashed.
Apart from you can also use NSZombieEnabled (BOOL) to get what is causing the application crash .More about NSZombieEnabled can be found here http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html
Note : here do make sure to make NSZombieEnabled set to NO at time of processing the application to submission to apple store.
Hope this helps.

App crashing with this error message - I cannot find anything about this after googling it- Can someone help please

Im not getting any compile time errors nor anything comes up when I run Build & Analyze. But at run time my app crashes when I click a uitextfield.
-[__NSCFType textFieldDidBeginEditing:]: unrecognized selector sent to instance 0x583cb90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType textFieldDidBeginEditing:]: unrecognized selector sent to instance 0x583cb90'
0 CoreFoundation 0x00fa25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010f6313 objc_exception_throw + 44
2 CoreFoundation 0x00fa40bb -[NSObject(NSObject)doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f13966 ___forwarding___ + 966
4 CoreFoundation 0x00f13522 _CF_forwarding_prep_0 + 50
5 UIKit 0x00394581 -[UIControl(Deprecated) sendAction:toTarget:forEvent:] + 67
6 UIKit 0x00396e62 -[UIControl(Internal) _sendActionsForEventMask:withEvent:] +
7 UIKit 0x0039ce11 -[UITextField willAttachFieldEditor:] + 404
8 UIKit 0x003aecdf -[UIFieldEditor becomeFieldEditorForView:] + 653
9 UIKit 0x0039ef98 -[UITextField _becomeFirstResponder] + 99
Chances are that you are either not properly retaining the object you assign as the delegate of your UITextField (e.g. you don't assign it to an outlet property declared retain in IB), or you are calling release or autorelease on an object that you do not own or that you saved into an ivar.
The object eventually gets disposed of, and later a different object happens to be created at the same memory location. But that object, of course, doesn't implement the UITextFieldDelegate protocol, so when the text field tries to send the delegate messages to it it gives you that error instead. Were an object not to be created at that same memory location, you'd get a crash with EXC_BAD_ACCESS instead.
In Interface Builder (or possibly in code, but more likely IB) you have the "Editing Did Begin" Sent Event linked to a method that doesn't exist in your code; perhaps it was renamed, or maybe you neglected to delete that link after deleting the action.
When editing begins in your textField the app tries to call the method indicated in IB and fails; "unrecognized selector" is saying that it doesn't recognize a method by that name.
Either just delete the link or delete it and replace it with an appropriate link.