Unable to find enum descriptor PBFieldDescriptorProto_Label while unit testing - ios

After adding the GoogleCast framework to the unit test target I'm getting the following exception right before the tests start to run. Apart from that the SDK is fully functional. I'd appreciate any ideas!
2014-02-25 18:03:08.475 otest[3786:303] Unknown Device Type. Using UIUserInterfaceIdiomPhone based on screen size
2014-02-25 18:03:08.593 otest[3786:303] *** Assertion failure in -[GCKPB_PBFieldDescriptor initWithFieldDescription:rootClass:], /Volumes/BuildData/pulse-data/agents/wpye22.hot/recipes/415961027/base/googlemac/iPhone/Chromecast/SDKv2/Protos/../../../../ThirdParty/ProtocolBuffers/objectivec/Classes/PBDescriptor.m:409
2014-02-25 18:03:08.596 otest[3786:303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to find enum descriptor PBFieldDescriptorProto_Label'
*** First throw call stack:
(
0 CoreFoundation 0x00b1d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x007958b6 objc_exception_throw + 44
2 CoreFoundation 0x00b1d448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x00010fee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UnitTests 0x077205dd -[GCKPB_PBFieldDescriptor initWithFieldDescription:rootClass:] + 1640
5 UnitTests 0x0771f52c +[GCKPB_PBDescriptor allocDescriptorForClass:rootClass:fields:fieldCount:enums:enumCount:ranges:rangeCount:storageSize:wireFormat:] + 173
6 UnitTests 0x076e550f +[GCKPB_PBFieldDescriptorProto descriptor] + 179
7 UnitTests 0x077226b2 +[GCKPB_PBGeneratedMessage initialize] + 100
8 libobjc.A.dylib 0x00796275 _class_initialize + 599
9 libobjc.A.dylib 0x0079d0f1 lookUpImpOrForward + 158
10 libobjc.A.dylib 0x0079d04e _class_lookupMethodAndLoadCache3 + 55
11 libobjc.A.dylib 0x007a512f objc_msgSend + 139
12 SenTestingKit 0x201086c6 +[NSObject(SenTestRuntimeUtilities) senIsASuperclassOfClass:] + 74
13 SenTestingKit 0x2010879e +[NSObject(SenTestRuntimeUtilities) senAllSubclasses] + 154
14 SenTestingKit 0x20106fa0 +[SenTestSuite updateCache] + 42
15 SenTestingKit 0x201071cf +[SenTestSuite suiteForBundleCache] + 93
16 SenTestingKit 0x20107241 +[SenTestSuite testSuiteForBundlePath:] + 101
17 SenTestingKit 0x201061fb +[SenTestProbe specifiedTestSuite] + 294
18 SenTestingKit 0x20106467 +[SenTestProbe runTests:] + 177
19 libobjc.A.dylib 0x007a7737 +[NSObject performSelector:withObject:] + 70
20 otest 0x00002372 otest + 4978
21 otest 0x000025c4 otest + 5572
22 otest 0x000026a5 otest + 5797
23 otest 0x00002031 otest + 4145
24 libdyld.dylib 0x0165570d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

OCUnit's behaviour is to go through each class and hence call +initialize:
But this is not handled properly by GCKPB_PBGeneratedMessage and this bug has already been reported here.
While waiting for a fix, a temporary solution might be to mock GCKPB_PBGeneratedMessage's +initialize method in your unit tests with OCMock (or any other mocking framework) by adding the following code to your test class:
#import <OCMock/OCMock.h>
#interface GCKPB_PBGeneratedMessage : NSObject
#end
and
+ (void)initialize
{
id mockCastGeneratedMessage = [OCMockObject mockForClass:[GCKPB_PBGeneratedMessage class]];
[[mockCastGeneratedMessage stub] initialize];
}
Edit
As of iOS sender API v2.3.0 953, this is now fixed and this workaround is no longer required.

I came across a similar error when doing Unit Tests using Specta. I manually ignored the assert by creating my own assertion handler.
Defined in a helper class:
#define SPT_fail(...) \
SPTSpec *spec = [[SPTCurrentTestCase class] spt_spec]; \
NSString *message = [NSString stringWithFormat:__VA_ARGS__]; \
[SPTCurrentTestCase recordFailureWithDescription:message inFile:spec.fileName atLine:(int)spec.lineNumber expected:YES]; \
xxxLoggingAssertionHandler.m:
#implementation xxxLoggingAssertionHandler
+ (void)load {
[xxxLoggingAssertionHandler addHandler];
}
- (void)handleFailureInMethod:(SEL)selector
object:(id)object
file:(NSString *)fileName
lineNumber:(NSInteger)line
description:(NSString *)format, ... {
// ignore chromecast asserts only
NSString *selectorName = NSStringFromSelector(selector);
BOOL ignore = [selectorName isEqualToString:#"initWithFieldDescription:rootClass:"] || [selectorName isEqualToString:#"allocDescriptorForClass:rootClass:fields:fieldCount:enums:enumCount:ranges:rangeCount:storageSize:wireFormat:"];
if (!ignore) {
SPT_fail(#"NSAssert Failure: Method %# for object %# in %##%i", selectorName, object, fileName, line);
}
}
- (void)handleFailureInFunction:(NSString *)functionName
file:(NSString *)fileName
lineNumber:(NSInteger)line
description:(NSString *)format, ... {
SPT_fail(#"NSCAssert Failure: Function (%#) in %##%i", functionName, fileName, line);
}
+ (void)addHandler {
NSAssertionHandler *assertionHandler = [[xxxLoggingAssertionHandler alloc] init];
[[[NSThread currentThread] threadDictionary] setValue:assertionHandler
forKey:NSAssertionHandlerKey];
}
+ (void)removeHandler {
[[[NSThread currentThread] threadDictionary] setValue:nil
forKey:NSAssertionHandlerKey];
}
#end

Related

UITraitCollection getter, which is not supported on iOS13

I'm trying to update my project for iOS13. I'm using UIScrollSlidingPages library in my application project.
I put this library in my UIViewController like below. I put my custom view in data source.
- (TTSlidingPage *)pageForSlidingPagesViewController:(TTScrollSlidingPagesController_Custom*)source atIndex:(int)index{
PhotoGalleryItemView *item = [[PhotoGalleryItemView alloc] initPhotoGalleryItem:[restaurantData.Galeri objectAtIndex:index] ParentViewController:self];
item.view.frame = _ViewPhotoContainer.frame;
TTSlidingPage *slidingPage = [[TTSlidingPage alloc] initWithContentViewController:item];
return slidingPage;
}
But when i run the app it crash despite i reload data with DispatchQueue Main Async like these solutions.
2019-11-08 09:42:22.760428+0300 GastroClub[5790:35896] WARNING: GoogleAnalytics 3.17 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:48): Uncaught exception: <PhotoGalleryItemView: 0x7f9eb1782db0> returned nil from -traitCollection, which is not allowed.
2019-11-08 09:42:22.925971+0300 GastroClub[5790:35896] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2019-11-08 09:42:22.988883+0300 GastroClub[5790:35896] *** Assertion failure in UITraitCollection * _Nonnull _UIGetCurrentFallbackTraitCollection(void)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3900.12.15/_UIFallbackEnvironment.m:91
2019-11-08 09:42:22.990119+0300 GastroClub[5790:35896] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: <NSInternalInconsistencyException> <PhotoGalleryItemView: 0x7f9eb1782db0> returned nil from -traitCollection, which is not allowed.
2019-11-08 09:42:27.776557+0300 GastroClub[5790:35896] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<PhotoGalleryItemView: 0x7f9eb1782db0> returned nil from -traitCollection, which is not allowed.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c4eda8 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff256c9c2a -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 UIKitCore 0x00007fff474abd67 _UIGetCurrentFallbackTraitCollection + 962
5 UIKitCore 0x00007fff47d00909 UIViewCommonInitWithFrame + 644
6 UIKitCore 0x00007fff47d00647 -[UIView initWithFrame:] + 98
7 UIKitCore 0x00007fff47cde48f -[UIImageView initWithFrame:] + 62
8 UIKitCore 0x00007fff47cffe99 -[UIView init] + 44
9 GastroClub 0x000000010816d313 -[UIImageView(Preloader) addPreloder] + 131
10 GastroClub 0x000000010816dcf6 -[UIImageView(Preloader) setImageWithURL_ShowPreloader:placeholderImage:options:progress:completed:] + 182
11 GastroClub 0x000000010816db69 -[UIImageView(Preloader) setImageWithURL_ShowPreloader:] + 105
12 GastroClub 0x00000001080c29f8 -[PhotoGalleryItemView viewDidLoad] + 200
13 UIKitCore 0x00007fff471cdb45 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
14 UIKitCore 0x00007fff471d2a9e -[UIViewController loadViewIfRequired] + 1084
15 UIKitCore 0x00007fff471d2ebb -[UIViewController view] + 27
16 UIScrollSlidingPages 0x000000010a06f2fd -[TTSlidingPage setContentViewController:] + 93
17 UIScrollSlidingPages 0x000000010a06f18b -[TTSlidingPage initWithContentViewController:] + 139
18 GastroClub 0x000000010806b32d -[RestaurantDetailViewController pageForSlidingPagesViewController:atIndex:] + 429
19 UIScrollSlidingPages 0x000000010a06b6cf -[TTScrollSlidingPagesController reloadPages] + 3455
20 GastroClub 0x0000000108060d42 __48-[RestaurantDetailViewController addPhotoSlider]_block_invoke + 50
21 libdispatch.dylib 0x000000010abc6dd4 _dispatch_call_block_and_release + 12
22 libdispatch.dylib 0x000000010abc7d48 _dispatch_client_callout + 8
23 libdispatch.dylib 0x000000010abd5de6 _dispatch_main_queue_callback_4CF + 1500
24 CoreFoundation 0x00007fff23bb1df9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
25 CoreFoundation 0x00007fff23baca59 __CFRunLoopRun + 2329
26 CoreFoundation 0x00007fff23babe16 CFRunLoopRunSpecific + 438
27 GraphicsServices 0x00007fff38438bb0 GSEventRunModal + 65
28 UIKitCore 0x00007fff4784fb68 UIApplicationMain + 1621
29 GastroClub 0x000000010801b900 main + 112
30 libdyld.dylib 0x00007fff51a1dc25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Then i tried to fix that with this solution. I put this method in my custom view like below:
#interface PhotoGalleryItemView (){
GCGaleri *galleryItem;
}
#property (weak, nonatomic) IBOutlet UIImageView *IMGViewGallery;
#end
#implementation PhotoGalleryItemView
- (id)initPhotoGalleryItem:(GCGaleri*)GalleryItem ParentViewController :(RestaurantDetailViewController*)ParentViewController {
if (self) {
galleryItem = GalleryItem;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[_IMGViewGallery setImageWithURL_ShowPreloader:[NSURL URLWithString:galleryItem.Foto]];
_IMGViewGallery.clipsToBounds = YES;
_IMGViewGallery.contentMode = UIViewContentModeScaleAspectFill;
}
// I put here
- (UITraitCollection *)traitCollection
{
if (#available(iOS 13.0, *)) {
[UITraitCollection setCurrentTraitCollection:[[UITraitCollection alloc]init]];
} else {
// Fallback on earlier versions
};
return [[UITraitCollection alloc]init];
}
#end
After that, i run my app it crash with these errors:
2019-11-08 10:03:40.570894+0300 GastroClub[5914:42170] [TraitCollection] Class PhotoGalleryItemView overrides the -traitCollection getter, which is not supported. If you're trying to override traits, you must use the appropriate API.
2019-11-08 10:03:40.571987+0300 GastroClub[5914:42170] [Assert] Current fallback trait collection contains one or more unspecified traits: {(
"_UITraitNameDisplayGamut",
"_UITraitNameDebugHighlight",
"_UITraitNameDisplayScale",
"_UITraitNameDisplayCornerRadius",
"_UITraitNamePresentationSemanticContext",
"_UITraitNameUserInterfaceLevel",
"_UITraitNameVibrancy",
"_UITraitNameLegibilityWeight",
"_UITraitNamePreferredContentSizeCategory",
"_UITraitNameAccessibilityContrast",
"_UITraitNameTouchLevel",
"_UITraitNameSemanticContext"
)}; traitCollection: <UITraitCollection: 0x600001984600; >; currentFallbackEnvironment: <PhotoGalleryItemView: 0x7fdeb1e9cac0>
How can i fix that issue? I can not update my library because it is no longer in active development.
I found the solution. When I slidingPage initiate then I show a preloader. My crash has occurred when I show the preloader. When I put my preloader in DispatchAsyncAfter like below I could fix my error:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self addPreloder];
__weak typeof(self) weakSelf = self;
[self sd_setImageWithURL:url
placeholderImage:placeholder
options:options
progress:progressBlock
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageUrl) {
if (completedBlock) {
completedBlock(image, error, cacheType, imageUrl);
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (weakSelf.preloding) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
[weakSelf.preloding stopAnimating];
[weakSelf.preloding removeFromSuperview];
[weakSelf removeActivityIndicator];
});
}
});
}
];
});
In swift 5 it work for me
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(0.5 * Double(NSEC_PER_SEC)) / Double(NSEC_PER_SEC), execute: {
// your code here
})

An error About Kiwi unit test

I am learning unit test.I am going to use Kiwi framework.I wrote a simple test code using Kiwi blow:
#import <Kiwi/Kiwi.h>
SPEC_BEGIN(SimpleStringSpec)
describe(#"SimpleString", ^{
context(#"when assigned to 'Hello world'", ^{
NSString *greeting = #"Hello world";
it(#"should exist", ^{
[[greeting shouldNot] beNil];
});
it(#"should equal to 'Hello world'", ^{
[[greeting should] equal:#"Hello world"];
});
});
});
SPEC_END
When testing the code, Project will crash with an error blow:
12:26:50.842 XCTest_Demo[8053:93923] _XCT_testBundleReadyWithProtocolVersion:minimumVersion: reply received
12:26:50.852 XCTest_Demo[8053:93923] _IDE_startExecutingTestPlanWithProtocolVersion:16
2016-05-25 12:26:50.856 XCTest_Demo[8053:93891] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation _invocationWithMethodSignature:frame:]: method signature argument cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0000000109a4dd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107949deb objc_exception_throw + 48
2 CoreFoundation 0x000000010990d71d +[NSInvocation _invocationWithMethodSignature:frame:] + 333
3 XCTest 0x0000000111b38ea9 -[XCTestCase initWithSelector:] + 167
4 XCTest 0x0000000111b38f08 +[XCTestCase testCaseWithSelector:] + 43
5 XCTest 0x0000000111b374cb +[XCTestSuite testSuiteForTestCaseWithName:] + 344
6 XCTest 0x0000000111b38181 -[XCTestSuite _initWithTestConfiguration:] + 508
7 XCTest 0x0000000111b38674 +[XCTestSuite testSuiteForTestConfiguration:] + 50
8 XCTest 0x0000000111b24979 -[XCTestDriver _runSuite] + 233
9 XCTest 0x0000000111b257d1 -[XCTestDriver _checkForTestManager] + 259
10 XCTest 0x0000000111b6fa9a _XCTestMain + 628
11 CoreFoundation 0x00000001099732ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
12 CoreFoundation 0x0000000109968f75 __CFRunLoopDoBlocks + 341
13 CoreFoundation 0x00000001099686d2 __CFRunLoopRun + 850
14 CoreFoundation 0x00000001099680f8 CFRunLoopRunSpecific + 488
15 GraphicsServices 0x000000010b74bad2 GSEventRunModal + 161
16 UIKit 0x0000000107daef09 UIApplicationMain + 171
17 XCTest_Demo 0x0000000107456c5f main + 111
18 libdyld.dylib 0x000000010a6a592d start + 1
19 ??? 0x0000000000000005 0x0 + 5
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What's wrong?

xcode - unrecognized selector sent to instance

I called method in another class (they are both singletons).
WebserviceHelper.h
#interface WebserviceHelper : NSObject {
int currentType;
NSString *SERVER_URL;
WebserviceManager *webService;
}
#property (nonatomic, assign) id delegate;
- (void)retrieveStudentwithCode:(NSString *)code {
currentType = STUDENT_TYPE;
NSString *param = [NSString stringWithFormat:#"token=uencom&cid=%#", code];
NSString *link = [NSString stringWithFormat:#"%#getStudentInfo", SERVER_URL];
[webService retrieveData:link withParameters:param];
}
After call webservice and get data it cached here in received data. I check and it works fine
but when it deliver to didFinishLoading error happen here
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)receivedData {
data = [NSMutableData new];
[data appendData:receivedData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
//it carsh here
[delegate: data];
}
Call stack:
2014-08-20 10:39:05.187 School-Link[1030:60b] -[WebserviceHelper :]: unrecognized selector sent to instance 0xa88a420
2014-08-20 10:39:05.188 School-Link[1030:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebserviceHelper :]: unrecognized selector sent to instance 0xa88a420'
*** First throw call stack:
(
0 CoreFoundation 0x01bf31e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018f08e5 objc_exception_throw + 44
2 CoreFoundation 0x01c90243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01be350b ___forwarding___ + 1019
4 CoreFoundation 0x01be30ee _CF_forwarding_prep_0 + 14
5 School-Link 0x00030c82 -[WebserviceManager connectionDidFinishLoading:] + 242
6 Foundation 0x016b9e49 ___NSURLConnectionDidFinishLoading_block_invoke + 40
7 Foundation 0x016507e1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 62
8 Foundation 0x014d8f5e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119
9 Foundation 0x014d8ec6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208
10 Foundation 0x014d8dd8 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
11 Foundation 0x014d9188 _NSURLConnectionDidFinishLoading + 43
12 CFNetwork 0x02a3169f ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 111
13 CFNetwork 0x02a2f3de ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 104
14 CoreFoundation 0x01b94c69 CFArrayApplyFunction + 57
15 CFNetwork 0x02998441 _ZN19RunloopBlockContext7performEv + 155
16 CFNetwork 0x02a7a3f4 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
17 CFNetwork 0x02998257 _ZN17MultiplexerSource7performEv + 299
18 CFNetwork 0x0299806c _ZN17MultiplexerSource8_performEPv + 76
19 CoreFoundation 0x01b7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x01b7c1d5 __CFRunLoopDoSources0 + 437
21 CoreFoundation 0x01b991ae __CFRunLoopRun + 910
22 CoreFoundation 0x01b989d3 CFRunLoopRunSpecific + 467
23 CoreFoundation 0x01b987eb CFRunLoopRunInMode + 123
24 GraphicsServices 0x0338d5ee GSEventRunModal + 192
25 GraphicsServices 0x0338d42b GSEventRun + 104
26 UIKit 0x005b0f9b UIApplicationMain + 1225
27 School-Link 0x00018f6d main + 141
28 libdyld.dylib 0x03026701 start + 1
29 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Try this, have a protocol declaration in WebserviceHelper.h like
#protocol studentDataDelegate <NSObject>
-(void)WebserviceHelper:(WebserviceHelper *)webserviceHelper didStudentDataDownloadCompleteWithData:(NSMutableData *)data;
#end
WebserviceHelper.m
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
[self.delegate WebserviceHelper:self didStudentDataDownloadCompleteWithData:data];
}
so which ever class confirms to the above protocol should implement the delegate method like,
#interface RequestingDataClass : UIViewController <studentDataDelegate>
by doing this you will receive the warning that you have not implemented didStudentDataDownloadCompleteWithData:method so do it like
-(void)WebserviceHelper:(WebserviceHelper *)webserviceHelper didStudentDataDownloadCompleteWithData:(NSMutableData *)data;
{
webserviceHelper.delegate=self;
// Do something with the `data`
}
You do no show the declaration of the delegate, however this statement:
[delegate: data];
Should be:
[delegate haveSomeData:data];
(or something similar)
did you create protocol in your WebserviceHelper.h file like this?
#protocol WebserviceHelperDelegate <NSObject>
#required
-(void)reciveData:(NSData *)data;//or your method
#end
decleare a property
#property (nonatomic,strong) id <WebserviceHelperDelegate> delegate;
then call this method like
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[self stopPostingToWebservice];
//it carsh here
[self.delegate reciveData: data];
}
And implement this method from where you call webservice class and assign delegate
-(void)reciveData:(NSData *)data{
}

UIApplicationMain crashing in xcode [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
My application is crashing as
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //Thread 1:signal SIGABRT
[pool release];
return retVal;
/*
int retVal = 0;
#autoreleasepool {
NSString *classString = NSStringFromClass([gTalkAppDelegate class]);
#try {
retVal = UIApplicationMain(argc, argv, nil, classString);
}
#catch (NSException *exception) {
NSLog(#"Exception - %#",[exception description]);
exit(EXIT_FAILURE);
}
}
return retVal;
*/
}
2014-01-07 15:41:25.881 testproject[28812:70b] -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184
2014-01-07 15:41:25.973 testproject[28812:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x281d184'
*** First throw call stack:
(
0 CoreFoundation 0x026d75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c028b6 objc_exception_throw + 44
2 CoreFoundation 0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x026c790b ___forwarding___ + 1019
4 CoreFoundation 0x026c74ee _CF_forwarding_prep_0 + 14
5 testproject 0x0000e7cd -[SecondViewController showData] + 1837
6 testproject 0x0000829d -[SecondViewController viewDidAppear:] + 1261
7 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
8 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
9 UIKit 0x00898fca -[UINavigationController viewDidAppear:] + 191
10 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
11 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
12 UIKit 0x008a827b -[UITabBarController viewDidAppear:] + 113
13 UIKit 0x0087ac48 -[UIViewController _setViewAppearState:isAnimating:] + 497
14 UIKit 0x0087b1d7 -[UIViewController __viewDidAppear:] + 146
15 UIKit 0x0087cb9f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
16 UIKit 0x0087b56a -[UIViewController _executeAfterAppearanceBlock] + 63
17 UIKit 0x007801a9 ___afterCACommitHandler_block_invoke_2 + 33
18 UIKit 0x0078012e _applyBlockToCFArrayCopiedToStack + 403
19 UIKit 0x0077ff7e _afterCACommitHandler + 568
20 CoreFoundation 0x0269f4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
21 CoreFoundation 0x0269f41f __CFRunLoopDoObservers + 399
22 CoreFoundation 0x0267d344 __CFRunLoopRun + 1076
23 CoreFoundation 0x0267cac3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x0267c8db CFRunLoopRunInMode + 123
25 GraphicsServices 0x035e09e2 GSEventRunModal + 192
26 GraphicsServices 0x035e0809 GSEventRun + 104
27 UIKit 0x00763d3b UIApplicationMain + 1225
28 testproject 0x0000213d main + 125
29 testproject 0x000020b5 start + 53
30 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
How can fix it.
Looking through your stacktrace you can see that in viewDidAppear you call a method called showData this can be seen from the two lines below.
5 gtalkhotdial 0x0000e7cd -[SecondViewController showData] + 1837
6 gtalkhotdial 0x0000829d -[SecondViewController viewDidAppear:] + 1261
Within this showData method you make a call to something (unfortunately we can't tell what) that tries to call -[__NSCFConstantString countByEnumeratingWithState:objects:count:]: and what ever that object is it, it doesn't have this method. To tell you anything more we need to see what is in the method showData. But your crash is clearly happening in there. If you what to know anything else please share that method implementation.
Look at your stack trace, the lines
2 CoreFoundation 0x02774903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
and
5 gtalkhotdial 0x0000e7cd -[SecondViewController showData] + 1837
should help you

CocoaLibSpotify: Unrecognized selector on Login and Search

I'm having a pretty consistent issue here, and have literally searched everywhere to no avail. I've been having a ton of problems with CocoaLibSpotify, and this error is just more hours being wasted of my employer, but anyways.
Whenever I attempt to login or do an SPSearch I get an unrecognized selector and the application crashes. Here's the code below. Thanks for your patience!
SPDispatchAsync(^{
NSError *error = nil;
//[SPSession class];
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size]
userAgent:#"com.mattie.montgomery.listenin"
loadingPolicy:SPAsyncLoadingManual
error:&error];
if (error != nil) {
NSLog(#"CocoaLibSpotify init failed: %#", error);
abort();
}
[[SPSession sharedSession] setDelegate:self];
[[SPSession sharedSession] attemptLoginWithUserName:#"USERNAME" password:#"PASSWORD"];
// playbackManager = [[SPPlaybackManager alloc] initWithPlaybackSession:[SPSession sharedSession]];
//[search addObserver:self forKeyPath:#"searchInProgress" options:NSKeyValueObservingOptionNew context:NULL];
// search = [SPSearch searchWithSearchQuery:#"What is love" inSession:[SPSession sharedSession]];
});
Here's the exception:
2014-01-13 13:24:48.890 ListenIn[47201:4303] +[NSError spotifyErrorWithCode:]: unrecognized selector sent to class 0x2cd8298
2014-01-13 13:24:48.979 ListenIn[47201:4303] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSError spotifyErrorWithCode:]: unrecognized selector sent to class 0x2cd8298'
* First throw call stack:
(
0 CoreFoundation 0x030835e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x02e068b6 objc_exception_throw + 44
2 CoreFoundation 0x031207a3 +[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0307390b __forwarding + 1019
4 CoreFoundation 0x030734ee _CF_forwarding_prep_0 + 14
5 ListenIn 0x00039a6b logged_in + 139
6 ListenIn 0x0018c1de sp_session_set_private_session + 538
7 ListenIn 0x000f0cf7 -[SPClientUpsellViewController .cxx_destruct] + 639639
8 ListenIn 0x0009c277 -[SPClientUpsellViewController .cxx_destruct] + 292887
9 ListenIn 0x0018af5f sp_session_process_events + 80
10 ListenIn 0x0003854c -[SPSession prodSessionForcefully] + 332
11 ListenIn 0x0003cf2c notify_main_thread_block_invoke + 44
12 ListenIn 0x0002b63d __54+[SPSession dispatchToLibSpotifyThread:waitUntilDone:]_block_invoke + 93
13 CoreFoundation 0x030421c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 16
14 CoreFoundation 0x0300b3f9 CFRunLoopDoBlocks + 361
15 CoreFoundation 0x03029843 __CFRunLoopRun + 2355
16 CoreFoundation 0x03028ac3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x03033e61 CFRunLoopRun + 129
18 ListenIn 0x0002b905 +[SPSession runBackgroundRunloop:] + 437
19 Foundation 0x02a5e597 -[NSThread main] + 76
20 Foundation 0x02a5e4f6 _NSThread_main + 1275
21 libsystem_pthread.dylib 0x05dc15fb _pthread_body + 144
22 libsystem_pthread.dylib 0x05dc1485 _pthread_struct_init + 0
23 libsystem_pthread.dylib 0x05dc6cf2 thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
First, don't put account credentials like your username and password on the public internet.
As for your problem, pasting in a big block of code isn't very helpful - which line actually generates the error?
Your commented out code at the bottom is in the wrong order - you can't add an observer to something until after you've created it.
Finally, please re-read the readme, specifically the part about threading. You only need to use SPDispatchAsync in very specific circumstances, and you should never be using it in normal usage like this.
The answer was to add the -ObjC linker flag and add the Facebook API to the project. Thanks to iKenndac for the suggestion.

Resources