UIDocumentInteractionControllerDelegate EXC_BAD_ACCESS in Swift - ios

I'm currently trying to open a file with another application using an instance of UIDocumentInteractionController. Everything works fine (e.g. showing the options dialog, opening the application) but when the app switch actually happens I receive a EXC_BAD_ACCESS instead of the didFinishSendingToApplication: delegate callback. Before I ported this code to Swift from Objective-C everything was working fine.
Any ideas whats is going wrong here?
self.documentInteractionController = UIDocumentInteractionController(URL: self.fileURL)
self.documentInteractionController!.UTI = "net.whatsapp.movie"
self.documentInteractionController!.delegate = self
Here is all of the stack trace I can get (the crash actually happens in the main function so I can't get anything more...):
* thread #1: tid = 0x12ef7e, 0x0000000182dd18c8 CoreFoundation`CFStringCreateCopy + 36, queue = 'com.apple.main-thread', stopreason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x0000000182dd18c8 CoreFoundation`CFStringCreateCopy + 36
frame #1: 0x0000000101df09d8 libswiftCore.dylib`function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Dead> of Swift.String.init (Swift.String.Type)(_cocoaString : Swift.AnyObject) -> Swift.String + 108
frame #2: 0x0000000101dd45b0 libswiftCore.dylib`Swift.String.init (Swift.String.Type)(_cocoaString : Swift.AnyObject) -> Swift.String + 24
frame #3: 0x0000000100253814 MyApp`#objc MyApp.MyViewController.documentInteractionController (MyApp.MyViewController)(ObjectiveC.UIDocumentInteractionController, didEndSendingToApplication : Swift.String) -> () + 84 at MyViewController.swift:0
frame #4: 0x0000000183dedf9c Foundation`__NSThreadPerformPerform + 372
frame #5: 0x0000000182ea4240 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #6: 0x0000000182ea34e4 CoreFoundation`__CFRunLoopDoSources0 + 264
frame #7: 0x0000000182ea1594 CoreFoundation`__CFRunLoopRun + 712
frame #8: 0x0000000182dcd2d4 CoreFoundation`CFRunLoopRunSpecific + 396
frame #9: 0x000000018c5e36fc GraphicsServices`GSEventRunModal + 168
frame #10: 0x0000000187992fac UIKit`UIApplicationMain + 1488
frame #11: 0x00000001000c6374 MyApp`main(argc=1, argv=0x000000016fdf79c0) + 124 at main.m:33
frame #12: 0x0000000194d8ea08 libdyld.dylib`start + 4

The real issue is that the delegate signature is wrong on the SDK. Instead of
documentInteractionController(controller: UIDocumentInteractionController, didEndSendingToApplication application: String)
you should use
documentInteractionController(controller: UIDocumentInteractionController, didEndSendingToApplication application: String?)
Please not the last ?, which says the application parameter can be nil, which it always is.
You should do the same to the willBeginSendingToApplication call, as it too can have a nil application parameter.
It's safe to ignore the warnings complaining about different optionality than expected by the protocol.

I met the same problem and spent days to try to fix this problem.
I finally found that the root cause of this error is from implementing func documentInteractionController(controller: UIDocumentInteractionController, didEndSendingToApplication application: String) in the class.
I removed this function and use willBeginSendingToApplication instead and the app will not crash on app switching.
Tested on real device running iOS 7.1 and iOS 8.3. FYI

Related

exc_bad_access only iOS Version < 9 - textfield deallocated (

My app doesn't work for Versions older than iOS 9.x
The APP throws an EXC_BAD_ACCESS exception at a textField. The textField is in a tableView.
I enabled Zombie Objects: "[_UILabelLayer opacity]: message sent to deallocated instance 0x81018770"
It doesn't appear at the beginning. It only crashs when I click on the tableView cells or when my 30 seconds timer refreshs the UI. (I disabled the timer, but there were no changes)
I tried dispatch_async(dispatch_get_main_queue()) and semaphores. I got no positive effects.
I check, whether the objects is nil, but it isn't:
if self.textField != nil {
if let textFieldNotNil = self.textField {
// textField.removeFromSuperview()
print("The Textfield \(textFieldNotNil.text)")
print("The Textfield \(textFieldNotNil)")
dispatch_async(dispatch_get_main_queue()) {
textFieldNotNil.text = strValue
}
}
}
When I use textField.removeFromSuperview() the app works again, but then there is no value inside the textfield. (That is clear, I removed it from the superview -.-)
Can I check, if my textfield is allocated? I can't find anything.
Have someone any other ideas?
EDIT
Sending a message to a nil would not cause your app to crash, I think.
I think this, too. My textfield isn't nil, too. But it crashs, this is the strange thing.
Do you have a StackTrace?
If u mean with StackTrace a do { try ... } catch {}-construct. No, I haven't. I searched for an example to surround a textfield.text = ".." with do/try/catch, but I can't find.
When does it crash? When you access textFieldNotNil.text?
This is the strange thing. It crashs in the line: textFieldNotNil.text = strValue
The error is that textFieldNotNil is deallocated. textFieldNotNil is called, when the user clicks on a tableViewCell or every 30 seconds.
Does this crash happen when you replace textFieldNotNil.text = strValue with [textFieldNotNil setText:strValue]?
Is it objectiv C? The compiler is bitching "Expected "," separator
You could also try textFieldNotNil.stringValue = strValue
I can't. My textFieldNotNil hasn't an attribute like stringValue. What's that?
Is self.textField declared weak?
Yes, it is. #IBOutlet weak var textField: UITextField?
Are you on a background thread when you call dispatch_async?
I don't know... I don't understand the stacktrace output so much.
* thread #1: tid = 0x38475f, 0x058f8e86 libsystem_kernel.dylib`__kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
frame #0: 0x058f8e86 libsystem_kernel.dylib`__kill + 10
frame #1: 0x058f5db9 libsystem_kernel.dylib`kill$UNIX2003 + 32
frame #2: 0x01f4829d CoreFoundation`___forwarding___ + 1069
frame #3: 0x01f47e4e CoreFoundation`__forwarding_prep_0___ + 14
frame #4: 0x034904e8 UIKit`-[UIView(Rendering) alpha] + 42
frame #5: 0x1287e70a UIKit`-[UILabelAccessibility isAccessibilityElement] + 90
frame #6: 0x12aba330 MessageUIFramework`-[MessageUILabelAccessibility isAccessibilityElement] + 104
frame #7: 0x128942c9 UIKit`-[UITextFieldAccessibility _accessibilityCountAccessibleChildren:] + 211
frame #8: 0x1289449c UIKit`__42-[UITextFieldAccessibility _updateButtons]_block_invoke + 46
frame #9: 0x055bf5ea libdispatch.dylib`_dispatch_call_block_and_release + 15
frame #10: 0x055e1bef libdispatch.dylib`_dispatch_client_callout + 14
frame #11: 0x055c52ef libdispatch.dylib`_dispatch_after_timer_callback + 156
frame #12: 0x055e1bef libdispatch.dylib`_dispatch_client_callout + 14
frame #13: 0x055d713a libdispatch.dylib`_dispatch_source_latch_and_call + 1063
frame #14: 0x055ce325 libdispatch.dylib`_dispatch_source_invoke + 375
frame #15: 0x055c74ee libdispatch.dylib`_dispatch_main_queue_callback_4CF + 532
frame #16: 0x01f528ee CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
frame #17: 0x01f105f0 CoreFoundation`__CFRunLoopRun + 2256
frame #18: 0x01f0fa5b CoreFoundation`CFRunLoopRunSpecific + 443
frame #19: 0x01f0f88b CoreFoundation`CFRunLoopRunInMode + 123
frame #20: 0x061a52c9 GraphicsServices`GSEventRunModal + 192
frame #21: 0x061a5106 GraphicsServices`GSEventRun + 104
frame #22: 0x0340a0b6 UIKit`UIApplicationMain + 1526
* frame #23: 0x0031584c CocoSoftIOSBaseApp`main + 140 at AppDelegate.swift:16
frame #24: 0x0560cac9 libdyld.dylib`start + 1
... a lot of more Threads

Swift 2.0 Random EXC_BAD_ACCESS

I'm running into some really strange EXC_BAD_ACCESS crashes which are totally reproducible with the last 2 Xcode 7 Beta versions (including the GM from last night):
When running my application, AFNetworking crashes with an EXC_BAD_ACCESS message in AFURLConnectionOperation.m line 154. More precisely, here is the stacktrace:
thread #1: tid = 0x23b173, 0x000000010b89beaf CoreFoundation`___forwarding___ + 767, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x000000010b89beaf CoreFoundation`___forwarding___ + 767
frame #1: 0x000000010b89bb28 CoreFoundation`__forwarding_prep_0___ + 120
* frame #2: 0x0000000105a4507e MyApp`-[AFURLConnectionOperation .cxx_destruct](self=0x00007fc4d873aa20, _cmd=(null)) + 494 at AFURLConnectionOperation.m:154
frame #3: 0x000000010af637bb libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 127
frame #4: 0x000000010af6e390 libobjc.A.dylib`objc_destructInstance + 93
frame #5: 0x000000010b94e7c6 CoreFoundation`-[NSObject(NSObject) __dealloc_zombie] + 150
frame #6: 0x00000001087ee9df Foundation`-[NSOperation dealloc] + 89
frame #7: 0x0000000105a3dca2 MyApp`-[AFURLConnectionOperation dealloc](self=0x00007fc4d873aa20, _cmd="dealloc") + 162 at AFURLConnectionOperation.m:216
frame #8: 0x000000010af78afe libobjc.A.dylib`objc_object::sidetable_release(bool) + 232
frame #9: 0x0000000105a31dd1 MyApp`__destroy_helper_block_((null)=0x00007fc4d8b27000) + 65 at AFHTTPRequestOperation.m:0
frame #10: 0x000000010d1226b1 libsystem_blocks.dylib`_Block_release + 128
frame #11: 0x000000010d0a549b libdispatch.dylib`_dispatch_client_callout + 8
frame #12: 0x000000010d08d34b libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1738
frame #13: 0x000000010b8a63e9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #14: 0x000000010b867939 CoreFoundation`__CFRunLoopRun + 2073
frame #15: 0x000000010b866e98 CoreFoundation`CFRunLoopRunSpecific + 488
frame #16: 0x000000010dd2cad2 GraphicsServices`GSEventRunModal + 161
frame #17: 0x00000001095c9676 UIKit`UIApplicationMain + 171
frame #18: 0x0000000105767d3f MyApp`main(argc=7, argv=0x00007fff5a541620) + 111 at main.m:33
frame #19: 0x000000010d0da92d libdyld.dylib`start + 1
I set enabled Zombie Objects in my scheme and got the following error
*** -[NSMutableURLRequest release]: message sent to deallocated instance 0x7fc4d8acc460
Would any one of you have an idea what is causing the crash? Using Xcode 6 works like a charm but I'd really like to use the new Swift features in my code ...
To answer my own question and leave this here for anyone out there who might be running into the same problem:
Apparently, the Swift 2.0 compiler doesn't like closures being passed an inout parameter. I had a closure in place which could be used to further customize my request which took an object of type NSMutableURLRequest as an inout parameter. Once changing this closure to simply return the request and removing the inout everything works as expected again ...

iOS 8 crashing in a weird pattern

I have spent over a ton of hours working on an app, it works perfectly on iOS 7, both on device and simulator. When I run it on iOS 8, it works perfectly on simulator. But for some reason, when I run it on my iOS 8 device, it starts crashing weirdly. If I implement CLLocation, the app will run smoothly for the first 5 times that I run it. Then it will crash the MOMENT I compile it for the next 5 times. After that 5 times, it starts compiling smoothly again. Then after 5 more times, it crashes on launch again, and the pattern continues.
IE. 1, run. 2. run. 3. run. 4. run. 5. run. 6-10.crash on launch, 11-15, run. 16-20 crash
HOWEVER, when I remove CLLocation, the app runs smoothly, but crashes on every 3rd launch. IE. 1. run. 2. run. 3. crash. 4. run. 5. run 6. crash.
I have been banging my head against the wall for like days without sleep on this. Can someone please explain to me why? For every crash on launch, the only error the console outputs is NSDictionary unknown selector.
I don't want my app to get rejected if Apple reviewers happen to run it at one of the "crash times"
Console Bt
(lldb) bt
* thread #3: tid = 0x12646, 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.root.default-qos', stop reason = breakpoint 1.1
frame #0: 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw
frame #1: 0x0000000187d8d094 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 220
frame #2: 0x0000000187d89e48 CoreFoundation`___forwarding___ + 928
frame #3: 0x0000000187c8f08c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #4: 0x0000000188c4f0dc Foundation`-[NSString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:] + 192
frame #5: 0x0000000188c4f23c Foundation`writeStringToURLOrPath + 72
* frame #6: 0x00000001000c9f1c Blurtalk`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:307
frame #7: 0x00000001000f0a94 Blurtalk`+[PFNetworkCommandRunner createRequest:](self=0x000000010027d1b8, _cmd=<unavailable>, command=0x0000000170056a70) + 268 at PFNetworkCommandRunner.m:61
frame #8: 0x00000001000f1044 Blurtalk`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010027d1b8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:132
frame #9: 0x00000001000f1748 Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
frame #10: 0x00000001000f16bc Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
frame #11: 0x00000001000f1f80 Blurtalk`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 240 at PFCachedCommandRunner.m:82
frame #12: 0x000000010009dcd8 Blurtalk`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170241e60, task=<unavailable>) + 200 at BFTask.m:335
frame #13: 0x000000010009d730 Blurtalk`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x000000017807a340) + 32 at BFTask.m:287
frame #14: 0x0000000100338f20 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #15: 0x0000000100338ee0 libdispatch.dylib`_dispatch_client_callout + 16
frame #16: 0x00000001003459a0 libdispatch.dylib`_dispatch_root_queue_drain + 1272
frame #17: 0x0000000100346f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
frame #18: 0x0000000198b852e4 libsystem_pthread.dylib`_pthread_wqthread + 816
I have been able to reproduce and narrow down your crash using NSZombieEnabled.
My backtrace:
2014-12-30 14:58:26.997 Proto[1398:513570] *** -[CFString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:]: message sent to deallocated instance 0x170e78fc0
(lldb) bt
* thread #7: tid = 0x7d622, 0x00000001864be440 CoreFoundation`___forwarding___ + 968, queue = 'com.apple.root.default-qos', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1864be440)
* frame #0: 0x00000001864be440 CoreFoundation`___forwarding___ + 968
frame #1: 0x00000001863c2b6c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #2: 0x000000018738a83c Foundation`writeStringToURLOrPath + 72
frame #3: 0x00000001002485bc Proto`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:308
frame #4: 0x000000010028a944 Proto`+[PFNetworkCommandRunner createRequest:](self=0x000000010054eea8, _cmd=<unavailable>, command=0x0000000170446990) + 308 at PFNetworkCommandRunner.m:62
frame #5: 0x000000010028aef4 Proto`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010054eea8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:133
frame #6: 0x000000010028b5fc Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
frame #7: 0x000000010028b570 Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
frame #8: 0x000000010028be40 Proto`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 248 at PFCachedCommandRunner.m:83
frame #9: 0x00000001001ad038 Proto`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170446ea0, task=<unavailable>) + 200 at BFTask.m:335
frame #10: 0x00000001001aca90 Proto`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x0000000171067b40) + 32 at BFTask.m:287
frame #11: 0x0000000100ab8e30 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #12: 0x0000000100ab8df0 libdispatch.dylib`_dispatch_client_callout + 16
frame #13: 0x0000000100ac59a0 libdispatch.dylib`_dispatch_root_queue_drain + 1280
frame #14: 0x0000000100ac6f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
frame #15: 0x00000001974312e4 libsystem_pthread.dylib`_pthread_wqthread + 816
This is a bug in the Parse SDK, specifically when Parse tries to get device information on an initial install. I suggest you report this bug to Parse directly and point them to this StackOverflow question.
Additional conversation here: Parse Objective C library crashes on [PFInternalUtils installationId]
EDIT: There is an open bug report for this issue here: https://developers.facebook.com/bugs/1548203598729083
you should create an one for all breakpoint that will stop on any exception, please read this article, it is a very useful technique.
http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions
by the way, NSDictionary does not have length, it seems like you made a mistake by confusing it with a NSString object.

iOS 6 EXC_BAD_ACCESS (code=2, address=0x15) When Presenting Game Center, But fine in iOS 7+

Trying to present my GKGameCenterViewController. It works fine in iOS 7, but when i try to.....
GKGameCenterViewController *gamecenterViewController = [[GKGameCenterViewController alloc]init];
gamecenterViewController.viewState = GKGameCenterViewControllerStateDefault;
gamecenterViewController.gameCenterDelegate = self;
[[CCDirector sharedDirector] presentModalViewController:gamecenterViewController animated:YES];
...in iOS 6, i get a iOS 6 EXC_BAD_ACCESS (code=2, address=0x15) error.
I've tried stepping in, but seems to step through ok until it gets to the funny looking code...
I've read many pre-existing and similar faults, but most seem to report additional output from the debugger, but I'm simply not getting anything more than the above quoted error...
This is my bt output after the crash took place..
(lldb) bt
*thread #1: tid = 0x697d9, 0x024a709b libobjc.A.dylib`objc_msgSend + 15, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=2, address=0x47)
frame #0: 0x024a709b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x0222fb4b GameKit`__55-[GKGameCenterViewController _setupChildViewController]_block_invoke_083 + 42
frame #2: 0x0222b896 GameKit`__61-[GKHostedViewController requestRemoteViewControllerIfNeeded]_block_invoke_0113 + 1167
frame #3: 0x00c9e48f UIKit`__block_global_11 + 154
frame #4: 0x026cd731 libdispatch.dylib`_dispatch_barrier_sync_f_slow_invoke + 89
frame #5: 0x026dc014 libdispatch.dylib`_dispatch_client_callout + 14
frame #6: 0x026cc7d5 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 296
frame #7: 0x038bdaf5 CoreFoundation`__CFRunLoopRun + 1925
frame #8: 0x038bcf44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #9: 0x038bce1b CoreFoundation`CFRunLoopRunInMode + 123
frame #10: 0x03c027e3 GraphicsServices`GSEventRunModal + 88
frame #11: 0x03c02668 GraphicsServices`GSEventRun + 104
frame #12: 0x007bfffc UIKit`UIApplicationMain + 1211 * frame #13: 0x0008c0d6 Monkey Puzzle`main(argc=1, argv=0xbffff040) + 134 at main.m:14 (lldb)
With Zombies turned on in the debug menu, the Backtrace looks slightly different
(lldb) bt
*thread #1: tid = 0x6fb94, 0x02b35286 libsystem_kernel.dylib`__kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
frame #0: 0x02b35286 libsystem_kernel.dylib`__kill + 10
frame #1: 0x02b335ec libsystem_kernel.dylib`kill$UNIX2003 + 32
frame #2: 0x03907aac CoreFoundation`___forwarding___ + 316
frame #3: 0x0390794e CoreFoundation`__forwarding_prep_0___ + 14
frame #4: 0x02230b4b GameKit`__55-[GKGameCenterViewController _setupChildViewController]_block_invoke_083 + 42
frame #5: 0x0222c896 GameKit`__61-[GKHostedViewController requestRemoteViewControllerIfNeeded]_block_invoke_0113 + 1167
frame #6: 0x00c9f48f UIKit`__block_global_11 + 154
frame #7: 0x026ce731 libdispatch.dylib`_dispatch_barrier_sync_f_slow_invoke + 89
frame #8: 0x026dd014 libdispatch.dylib`_dispatch_client_callout + 14
frame #9: 0x026cd7d5 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 296
frame #10: 0x038beaf5 CoreFoundation`__CFRunLoopRun + 1925
frame #11: 0x038bdf44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #12: 0x038bde1b CoreFoundation`CFRunLoopRunInMode + 123
frame #13: 0x03c037e3 GraphicsServices`GSEventRunModal + 88
frame #14: 0x03c03668 GraphicsServices`GSEventRun + 104
frame #15: 0x007c0ffc UIKit`UIApplicationMain + 1211 * frame #16: 0x0008cba6 Monkey Puzzle`main(argc=1, argv=0xbffff00c) + 134 at main.m:14 (lldb)
When doing a Product/Profile/Zombies run, I received this after pressing the button in my menu at the 40 second mark...
Any advice please?
OK fixed it....
I have a method in a custom class that handles weather or not to bring up all leaderboards or a specific one... here is one example of how i call it...
-(void)displayLeaderboard:(id)sender
{
[[ABGameKitHelper sharedHelper] showLeaderboard:#""];
}
If i pass an empty string to it, its meant to show just the gamcenter main screen, with all the leaderboards. If i send it any string, it will show the default leaderboard ("level 1"), and if i pass it a valid leaderboardID, it will show that leaderboard....
Used to look like this...
-(void) showLeaderboard:(NSString*)leaderboardId
{
GKGameCenterViewController *gamecenterViewController = [[GKGameCenterViewController alloc]init];
GKLeaderboardViewController *leaderboardViewController = [[GKLeaderboardViewController alloc]init];
if ([leaderboardId isEqualToString:#""])
{
gamecenterViewController.viewState = GKGameCenterViewControllerStateDefault;
gamecenterViewController.gameCenterDelegate = self;
[[self topViewController] presentViewController:gamecenterViewController animated:YES completion:nil];
}
else
{
leaderboardViewController.leaderboardDelegate = self;
leaderboardViewController.category = leaderboardId;
[[self topViewController] presentViewController:leaderboardViewController animated:YES completion:nil];
}
}
This worked FINE on iOS 7, however iOS 6 would crash with the information i provided in the above question.
It turns out that the solution was to include the definition inside the if statement. I have no idea why iOS 6 isn't happy with declaring both of them, and only using one... The only reason i noticed something was us was because i saw [GKLeaderboardViewController _endDelayingPresentation]: message sent to deallocated instance 0xaac8d20 in the debug, when (although similar) i was actually always only ever needing to call the GKGameCenterViewController... So moving the declarations to within the IF statement solved this issue that would have otherwise not allowed me to deploy to iOS 6...
I would really love to read some comments on this to help me understand obj-c a little better, thanks....

GPPSignIn sharedInstance -> EXC_BAD_ACCESS (code = EXC_I386_GPFLT)

It seems that everything was fine for a long time and yesterday without any visible reasons I started to get error
EXC_BAD_ACCESS (code = EXC_I386_GPFLT)
on the next line on emulator (everything is ok on real device):
GPPSignIn *signIn = [GPPSignIn sharedInstance];
After enabling NSZombie message changed to
exc_breakpoint (code=exc_i386_bpt subcode=0x0).
It is very strange because even if this line is only one in the viewDidLoad and it is the first view controller in the app I get error time after time (~every 3-4 app launch). I didn't make any changes to app configuration.
I will be grateful for any help. Thank you!
UPD: error occurs in libobjc.A.dylib
as I can see.
UPD:
UPD:
2014-03-31 13:54:13.611 SomeApp[450:3c07] *** -[CFString retain]: message sent to deallocated instance 0x10c2ef050
(lldb) bt
* thread #6: tid = 0x2a3b, 0x0000000103978cc4 CoreFoundation`___forwarding___ + 772, queue = 'NSOperationQueue 0x10ea2b870', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
* frame #0: 0x0000000103978cc4 CoreFoundation`___forwarding___ + 772
frame #1: 0x0000000103978938 CoreFoundation`__forwarding_prep_0___ + 120
frame #2: 0x00000001039fb3c7 CoreFoundation`+[__NSArrayI __new:::] + 87
frame #3: 0x000000010395d386 CoreFoundation`+[NSArray arrayWithObjects:] + 566
frame #4: 0x00000001002dea06 SomeApp `+[GPPSignIn versionFromServerData:currentVersion:] + 832
frame #5: 0x00000001002dec24 SomeApp `__28-[GPPSignIn checkSDKVersion]_block_invoke + 197
frame #6: 0x0000000100277e64 SomeApp `-[GTMHTTPFetcher connectionDidFinishLoading:] + 714
frame #7: 0x000000010152036b Foundation`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 48
frame #8: 0x000000010145763b Foundation`-[NSBlockOperation main] + 75
frame #9: 0x00000001014a5d34 Foundation`-[__NSOperationInternal _start:] + 623
frame #10: 0x00000001014a7c0b Foundation`__NSOQSchedule_f + 64
frame #11: 0x000000010414372d libdispatch.dylib`_dispatch_client_callout + 8
frame #12: 0x0000000104131eab libdispatch.dylib`_dispatch_async_redirect_invoke + 174
frame #13: 0x000000010414372d libdispatch.dylib`_dispatch_client_callout + 8
frame #14: 0x0000000104133b27 libdispatch.dylib`_dispatch_root_queue_drain + 380
frame #15: 0x0000000104133d12 libdispatch.dylib`_dispatch_worker_thread2 + 40
frame #16: 0x0000000104490ef8 libsystem_pthread.dylib`_pthread_wqthread + 314
(lldb)
This is a strange issue to track down. I've been having the same problem with the [CFString retain]: crash only in the simulator (runs fine on device), but when I tried to run Zombies in Instruments it would never show a zombie.
After tons of searching, your question lead me to use the backtrace command to find out that the Google+ SDK was causing the issue.
While this is only a workaround until Google fixes the issue, you can get your app to run on the simulator by wrapping your GPPSignIn in precompiler directives that check if you are running in the simulator:
#if !(TARGET_IPHONE_SIMULATOR)
- (GPPSignIn *) googlePlusSession {
NSLog(#"Not running on simulator");
if(_googlePlusSession == nil) {
_googlePlusSession = [GPPSignIn sharedInstance];
_googlePlusSession.clientID = kGoogleClientId;
_googlePlusSession.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,nil];
_googlePlusSession.delegate = self;
[_googlePlusSession trySilentAuthentication];
}
return _googlePlusSession;
}
#endif
Obviously this screws up the Google+ functionality in your app when running on the simulator, but in my case that was much better than not being able to launch at all. Hope this helps.

Resources