I'm trying to integrate FB into an existing iOS app.
I've modified the HelloFacebookSample app to use my app ID, display name, and bundle identifier. I can run it and post from it just fine (running in the iOS 6 emulator). So that leads me to believe my settings on developers.facebook.com are correct.
Next I looked at the code in the app delegate and view controller in the sample and duplicated it in my own code. The first bit of Facebook code that gets executed is in the app delegate, in applicationDidBecomeActive:. I execute the same two lines as the sample app:
[FBAppEvents activateApp];
[FBAppCall handleDidBecomeActive];
If I run my program, I eventually get EXC_BAD_ACCESS (code=2, address=0x0). In the debug navigator I see:
#0 0x0253309f in objc_msgSend ()
#1 0x0251eb2e in objc_setProperty_non_gc ()
#2 0x0251ed0d in objc_setProperty ()
#3 0x00446798 in -[FBRequestMetadata setCompletionHandler:] at /Users/chrisp/tmp/build- sdk/ios-sdk/src/FBRequestConnection.m:70
#4 0x004464eb in -[FBRequestMetadata initWithRequest:completionHandler:batchEntryName:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:94
#5 0x00446cb6 in -[FBRequestConnection addRequest:completionHandler:batchEntryName:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:324
#6 0x00446bdb in -[FBRequestConnection addRequest:completionHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequestConnection.m:312
#7 0x0044048a in -[FBRequest startWithCompletionHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBRequest.m:149
#8 0x0045ec70 in +[FBUtility fetchAppSettings:callback:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBUtility.m:263
#9 0x0046e06b in +[FBSettings publishInstall:withHandler:isAutoPublish:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBSettings.m:334
#10 0x0046dc0c in +[FBSettings autoPublishInstallImpl:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBSettings.m:217
#11 0x00e27e83 in __NSFireDelayedPerform ()
#12 0x02a9d376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#13 0x02a9ce06 in __CFRunLoopDoTimer ()
#14 0x02a84a82 in __CFRunLoopRun ()
#15 0x02a83f44 in CFRunLoopRunSpecific ()
#16 0x02a83e1b in CFRunLoopRunInMode ()
#17 0x0339f7e3 in GSEventRunModal ()
#18 0x0339f668 in GSEventRun ()
#19 0x0120665c in UIApplicationMain ()
#20 0x0000230d in main at /Users/craig/Documents/Projects/MyProject/main.m:14
If I remove [FBAppCall handleDidBecomeActive] I get the same result. So this seems to be a result of [FBAppEvents activateApp].
If I remove [FBAppEvents activateApp], which I understand to be optional anyway, and only call [FBAppCall handleDidBecomeActive], I can launch the app. But then when I try to create an instance of FBLoginView in my view controller:
FBLoginView * loginview = [[FBLoginView alloc] init];
I get the same error (EXC_BAD_ACCESS (code=2, address=0x0)):
#0 0x0253309f in objc_msgSend ()
#1 0x0251eb2e in objc_setProperty_non_gc ()
#2 0x0251ed0d in objc_setProperty ()
#3 0x0046d47d in -[FBLoginView setSessionStateHandler:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:52
#4 0x0046b6f8 in -[FBLoginView initializeBlocks] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:177
#5 0x0046ba1c in -[FBLoginView initialize] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:212
#6 0x0046b432 in -[FBLoginView initWithFrame:] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:119
#7 0x0124528f in -[UIView init] ()
#8 0x0046b252 in -[FBLoginView init] at /Users/chrisp/tmp/build-sdk/ios-sdk/src/FBLoginView.m:80
#9 0x0001c0ea in -[MyViewController postToFacebook:] at /Users/craig/Documents/Projects/MyProject/Classes/MyViewController.mm:8040
#10 0x00015c18 in -[MyViewController copy:to:] at /Users/craig/Documents/Projects/MyProjects/Classes/MyViewController.mm:6624
#11 0x000225ee in -[MyViewController menuItemSelected:] at /Users/craig/Documents/Projects/MyProjects/Classes/MyViewController.mm:10003
#12 0x00e27e83 in __NSFireDelayedPerform ()
#13 0x02a9d376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#14 0x02a9ce06 in __CFRunLoopDoTimer ()
#15 0x02a84a82 in __CFRunLoopRun ()
#16 0x02a83f44 in CFRunLoopRunSpecific ()
#17 0x02a83e1b in CFRunLoopRunInMode ()
#18 0x0339f7e3 in GSEventRunModal ()
#19 0x0339f668 in GSEventRun ()
#20 0x0120665c in UIApplicationMain ()
#21 0x0000230d in main at /Users/craig/Documents/Projects/MyProject/main.m:14
Don't be fooled by the fact that I'm obviously not creating my FBLoginView in viewDidLoad. The point is that the first call to anything that tries to do anything with my Facebook session fails in the same way. It looks like it's trying to do something with a handler in both cases. The identical code works with MY Facebook identifier, bundle ID, etc. in the sample code, but doesn't work in my app. I'm suspecting compiler/linker settings or some other configuration difference between my app and the sample, but I'm not sure where to begin to look. Everything I've looked at looks the same between my app and the sample.
I've tried a lot of different ways to open a Facebook session and get the permissions I need, but they all fail the same way. This seemed like a good one to post here since the sample works but the same code in my app doesn't.
Thanks for your help.
EDIT: I see in my build settings that the sample app uses ARC. I do not. I'm hesitant to convert a large, functioning app at this point in its lifecycle.
Related
I have two location managers, one on a view controller with a map the other one in a separate controller that I present as modal. The issue is that every time I present that modal controller, I get a crash with the following backtrace.
I've tried setting delegates to nil, or setting the actual location manager to nil on viewWillDisappear and then re-initialising them on viewWillAppear, but still the issue persists. Any help would be greatly appreciated.
#0 0x9105fafa in mach_msg_trap ()
#1 0x91060267 in mach_msg ()
#2 0x016d313a in __CFRunLoopServiceMachPort ()
#3 0x01636580 in __CFRunLoopRun ()
#4 0x01635db4 in CFRunLoopRunSpecific ()
#5 0x01635ccb in CFRunLoopRunInMode ()
#6 0x026a6879 in GSEventRunModal ()
#7 0x026a693e in GSEventRun ()
#8 0x003e1a9b in UIApplicationMain ()
#9 0x000028b2 in main (argc=1, argv=0xbfffeca4) at /Users/penushlievm/Desktop/DailyPlanner 2/DailyPlanner 2/main.m:16
#10 0x00002825 in start ()
try using one location manager globally instead of two.
I'm finishing off an app for iOS 3.0 and up to run on the iPhone and iPod Touch. It's working fine on iOS4.0 and up, but when I backtest it on a second generation iPod Touch running iOS 3.0 the launch image shows and I'm met with the following:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)'
2012-01-15 09:35:53.025 MyApp[3026:207] Stack: (
808001701,
805397928,
807551015,
807550919,
810902709,
815043196,
815042704,
814682908,
814682012,
814970032,
814968048,
814966908,
839149932,
807750263,
807747947,
814678868,
814672532,
61527,
10764
)
terminate called after throwing an instance of 'NSException'
(gdb) backtrace
#0 0x31dd594c in __kill ()
#1 0x31dd5940 in kill ()
#2 0x31dd5934 in raise ()
#3 0x31deccfe in abort ()
#4 0x374ef848 in __gnu_cxx::__verbose_terminate_handler ()
#5 0x300166c0 in _objc_terminate ()
#6 0x374ecf3c in __cxxabiv1::__terminate ()
#7 0x374ecfb4 in std::terminate ()
#8 0x374ed0dc in __cxa_throw ()
#9 0x300165e4 in objc_exception_throw ()
#10 0x30224026 in +[NSException raise:format:arguments:] ()
#11 0x30223fc6 in +[NSException raise:format:] ()
#12 0x305564b4 in -[NSKeyedUnarchiver initForReadingWithData:] ()
#13 0x3094927c in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
#14 0x30949090 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
#15 0x308f131c in -[UIApplication _loadMainNibFile] ()
#16 0x308f0f9c in -[UIApplication _runWithURL:sourceBundleID:] ()
#17 0x309374b0 in -[UIApplication handleEvent:withNewEvent:] ()
#18 0x30936cf0 in -[UIApplication sendEvent:] ()
#19 0x3093687c in _UIApplicationHandleEvent ()
#20 0x3204696c in PurpleEventCallback ()
#21 0x30254a76 in CFRunLoopRunSpecific ()
#22 0x3025416a in CFRunLoopRunInMode ()
#23 0x308f0354 in -[UIApplication _run] ()
#24 0x308eea94 in UIApplicationMain ()
#25 0x0000f056 in main (argc=1, argv=0x2ffff7c8) at ...... Classes/main.m:16
Current language: auto; currently objective-c
Any ideas what this is and how to fix it?
I'm building in Xcode 4.2.1.
PS - The problem is not resolved by cleaning the build or by resaving .xib files. Sometimes the app will get past this stage but will crash for apparently the same reason when it sees a later .xib, say in loading a view controller.
This answer I believe covers what Ikuragames might have given (he's not near his computer). On his behalf, to solve the problem in Xcode 4.2.1 click on the .xib file and in the file properties panel on the right hand side, set the deployment to "iOS 3.0" (in my case) and development to "Interface Builder 3.0" (again in my case). Do this for every single .xib file in the project.
It's worth keeping in mind that Xcode 4.2.1 might well set defaults of "iOS 5.0" for the deployment here, to match the current SDK, and "Xcode 4.1" for the document type. Why Xcode doesn't just match the deployment target with the project deployment target I'm not sure...
If this still doesn't work or you're very paranoid by this stage, catch the exception raised by the NSKeyedUnarchiver when loading the .xib file and there create the view programmatically.
Very infrequently, our app is crashing because it receives SIGKILL. The circumstances are different, but the backtrace is always the same:
#0 0x94a00afa in mach_msg_trap ()
#1 0x94a01267 in mach_msg ()
#2 0x00fa9d5c in _UIPasteboardServerContainsTypesAtIndex ()
#3 0x00faa9ae in UIPasteboardServerContainsTypesAtIndex ()
#4 0x00fa5417 in -[UIPasteboard containsPasteboardTypes:] ()
#5 0x00de4054 in -[UITextField canPerformAction:withSender:] ()
#6 0x087038a8 in -[UIResponder(UITextAccessibilityUtilities) _accessibilityHasTextOperations] ()
#7 0x08704df5 in -[UIAccessibilityTextFieldElement _accessibilityHasTextOperations] ()
#8 0x08791dcf in -[NSObject(AXPrivCategory) accessibilityAttributeValue:] ()
#9 0x0878a3b4 in _copyMultipleAttributeValuesCallback ()
#10 0x087c5c95 in _AXXMIGCopyMultipleAttributeValues ()
#11 0x087c0a6c in _XCopyMultipleAttributeValues ()
#12 0x087c8e66 in mshMIGPerform ()
#13 0x020cf1c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#14 0x02034022 in __CFRunLoopDoSource1 ()
#15 0x0203290a in __CFRunLoopRun ()
#16 0x02031db4 in CFRunLoopRunSpecific ()
#17 0x02031ccb in CFRunLoopRunInMode ()
#18 0x02a43879 in GSEventRunModal ()
#19 0x02a4393e in GSEventRun ()
#20 0x00d2ba9b in UIApplicationMain ()
#21 0x0000284d in main (argc=1, argv=0xbfffed44) at [myapp]/main.m:14
#22 0x000027c5 in start ()
How would I go about finding out what is causing this crash?
The SIGKILL is sent to apps for any kind of exceptions. Se we have to make an educated guess what the exception reason would be in this case. In the above case it looks like accessibility is checking for a certain kind of pasteboard type to be present.
Since this is happening in Apple code most likely this is a bug in iOS, because the containsPasteboardTypes: method should never throw an exception. Only possibly if the passed parameter is nil, but then the bug would lie in UIAccessibilityTextFieldElement which too is Apple's responsibility.
Long story short: you need to file a radar. As a workaround you can add an #try block around the offending operation. This would catch and ignore the exception.
I am working on simple iphone application. where i am working on two views. I pushed the other view controller first and when i am removing the current view as to go back to the old view controller i am getting [CALayer retain]. EXEC_BAD_ACCESS.
In gdb, i tried backtrace command to see the problem which i have given below, but i am not able to find any. If anyone can help me out with this it will be great.
(gdb) backtrace
#0 0x02e21434 in ___forwarding___ ()
#1 0x02e209f2 in __forwarding_prep_0___ ()
#2 0x02dc7f58 in CFRetain ()
#3 0x02dc7a65 in CFArrayCreate ()
#4 0x02dfe043 in -[__NSPlaceholderArray initWithObjects:count:] ()
#5 0x0296eda3 in -[CALayerArray copyWithZone:] ()
#6 0x02ea380a in -[NSObject copy] ()
#7 0x004f742a in -[UIView dealloc] ()
#8 0x00214cb2 in NSPopAutoreleasePool ()
#9 0x004d3698 in _UIApplicationHandleEvent ()
#10 0x035fe17c in PurpleEventCallback ()
#11 0x02df289c in CFRunLoopRunSpecific ()
#12 0x02df18a8 in CFRunLoopRunInMode ()
#13 0x035fc89d in GSEventRunModal ()
#14 0x035fc962 in GSEventRun ()
#15 0x004d1372 in UIApplicationMain ()
#16 0x00002074 in main (argc=1, argv=0xbffff020) at /Users/jtong/Desktop/Elle/main.m:14
Thanks,
Aby
Sounds like you're also explicitly releasing something that you've already autoreleased.
Use Instruments and enable Zombies. This will trace where each object was retained and released and will hell you diagnose where the extra release is occurring.
How to run iPhone program with Zombies instrument?
I have a iPhone/iPad app (universal binary) with a regular UIWebView that displays webpages on the Internet. When the user presses on a Youtube embed, the iPhone app performs normally -- opening up the video player, when you close it, it returns to the app. However, on the iPad it crashes with
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow addEventMonitor:]: unrecognized selector sent to instance 0x1219c0'
#0 0x30c8e0a0 in __kill ()
#1 0x30c8e096 in kill ()
#2 0x30c8e088 in raise ()
#3 0x30ca2210 in abort ()
#4 0x32944a22 in __gnu_cxx::__verbose_terminate_handler ()
#5 0x335657ca in _objc_terminate ()
#6 0x32942df4 in __cxxabiv1::__terminate ()
#7 0x32942e48 in std::terminate ()
#8 0x32942f18 in __cxa_throw ()
#9 0x335646aa in objc_exception_throw ()
#10 0x32c9517a in -[NSObject doesNotRecognizeSelector:] ()
#11 0x32c94b00 in ___forwarding___ ()
#12 0x32c316d0 in __forwarding_prep_0___ ()
#13 0x32810492 in -[MPInactivityMonitor initForWindow:inactivityDuration:delegate:] ()
#14 0x32831dfe in -[MPFullScreenVideoViewController _createInactivityMonitor] ()
#15 0x328324bc in -[MPFullScreenVideoViewController showOverlayAnimated:] ()
#16 0x32833612 in -[MPAbstractFullScreenVideoViewController setControlsOverlayVisible:animate:] ()
#17 0x3281fca4 in -[UIMoviePlayerController setControlsOverlayVisible:disableAutohide:animate:] ()
#18 0x330bb444 in -[YTMovieView _switchToVideo:] ()
#19 0x330bb028 in -[YTMovieView willShowForVideo:inList:orVideoID:] ()
#20 0x04b8d142 in dyld_stub_time ()
#21 0x04b8b82e in dyld_stub_time ()
#22 0x32c2616c in -[NSObject performSelector:withObject:withObject:] ()
#23 0x3152716c in -[UIApplication sendAction:to:from:forEvent:] ()
#24 0x3152710c in -[UIApplication sendAction:toTarget:fromSender:forEvent:] ()
#25 0x315270de in -[UIControl sendAction:to:forEvent:] ()
#26 0x31526e30 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#27 0x3152747e in -[UIControl touchesEnded:withEvent:] ()
#28 0x31525e54 in -[UIWindow _sendTouchesForEvent:] ()
#29 0x3152579c in -[UIWindow sendEvent:] ()
#30 0x315213be in -[UIApplication sendEvent:] ()
#31 0x31520d2a in _UIApplicationHandleEvent ()
#32 0x30d62b32 in PurpleEventCallback ()
#33 0x32c23d9c in CFRunLoopRunSpecific ()
#34 0x32c234e0 in CFRunLoopRunInMode ()
#35 0x30d620da in GSEventRunModal ()
#36 0x30d62186 in GSEventRun ()
#37 0x314d54c8 in -[UIApplication _run] ()
#38 0x314d39f2 in UIApplicationMain ()
(I don't even see my app in the stack trace (except for the top level main.m)
In iPad Mobile Safari, on the same webpage, the video will play in-place on the webpage. Is there anything I have to do to enable that? Or did I forget to enable something?
As i understand this problem appers only on the universal binaries, that compiled under iPhone OS 3.1.3 and less. And not only youtube videos, but also for all kinds of media files loaded into the UIWebView.
As a solution you may override UIWindow and add some dummy methods.
#interface MyWindow : UIWindow {
}
#end
#implementation MyWindow {
- (void)addEventMonitor:(void *)monitor {}
- (void)pendingMouseUpCount {}
}