Facebook登录,让自己陷入了一点点。
不幸的是,对于我正在做的工作,我只能访问运行xcode 3.2.6的Snow Leopard并且无法改变。从过去的爆炸我知道。
要使用FB SDK 3.0让facebook登录工作,我使用了:
AppDelegate.h:
#import <FacebookSDK/FacebookSDK.h>
....
@property (retain, nonatomic) FBSession *session;
AppDelegate.m:
@synthesize session = _session;
...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [self.session handleOpenURL:url];
}
然后在我的FBLoginViewController.m viewDidLoad:
中MyAppDelegate *appDelegate;
appDelegate = [[UIApplication sharedApplication]delegate];
if (!appDelegate.session.isOpen) {
appDelegate.session = [[FBSession alloc] init];
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
}];
}
}
现在这适用于模拟器4.3。我想确认我已经在plist中正确设置了fb App Id,应用程序设置正确等等。
然而,在使用IOS 6的设备上进行测试时,它会崩溃并显示崩溃日志的相关部分:
Exception Type: EXC_CRASH (SIGSYS)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp 0x000e7cac 0x59000 + 584876
1 libdispatch.dylib 0x34a384b4 0x34a37000 + 5300
2 libdispatch.dylib 0x34a39836 0x34a37000 + 10294
3 MyApp 0x000e7ca0 0x59000 + 584864
4 MyApp 0x000d9d08 0x59000 + 527624
5 MyApp 0x000d9934 0x59000 + 526644
6 MyApp 0x000da6c6 0x59000 + 530118
7 MyApp 0x0005b1f0 0x59000 + 8688
8 MyApp 0x000660a4 0x59000 + 53412
9 UIKit 0x336130a0 0x33525000 + 975008
10 UIKit 0x33613052 0x33525000 + 974930
11 UIKit 0x33613030 0x33525000 + 974896
12 UIKit 0x336128e6 0x33525000 + 973030
13 UIKit 0x33612ddc 0x33525000 + 974300
14 UIKit 0x3353b5ec 0x33525000 + 91628
15 UIKit 0x335287fc 0x33525000 + 14332
16 UIKit 0x33528116 0x33525000 + 12566
17 GraphicsServices 0x382ab5a0 0x382a5000 + 26016
18 GraphicsServices 0x382ab1ce 0x382a5000 + 25038
19 CoreFoundation 0x3331c170 0x33285000 + 618864
20 CoreFoundation 0x3331c112 0x33285000 + 618770
21 CoreFoundation 0x3331af94 0x33285000 + 614292
22 CoreFoundation 0x3328deb8 0x33285000 + 36536
23 CoreFoundation 0x3328dd44 0x33285000 + 36164
24 GraphicsServices 0x382aa2e6 0x382a5000 + 21222
25 UIKit 0x3357c2f4 0x33525000 + 357108
26 MyApp 0x0005b012 0x59000 + 8210
27 MyApp 0x0005afc8 0x59000 + 8136
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x0000004e r1: 0x00000000 r2: 0x00000000 r3: 0x00000000
r4: 0x3b091bd0 r5: 0x2fda7c0c r6: 0x1cd560e0 r7: 0x2fda6734
r8: 0x00000000 r9: 0x2fda6764 r10: 0x1cd560e0 r11: 0x1cdac4d0
ip: 0x000e7c0d sp: 0x2fda672c lr: 0x34a384b7 pc: 0x000e7cac
cpsr: 0x60000010
我尝试过:
现在很明显使用xcode 3.2.6我无法通过xcode运行并访问控制台以便在我的IOS 6设备上进一步调试。因此,我将项目发送给了一位朋友(没有付费帐户,因此无法在设备上测试),他们确认它在xcode 4.5和模拟器6上工作。
因此,如果它在模拟器6和4.3上工作,为什么它不适用于IOS 6设备?我有点难过......
在玩完之后(只是评论线等)我认为它在这一行崩溃:
appdelagate.session = [[FBSession aloc] init];
但我发现很难确定或不知道为什么。
会喜欢一些想法或帮助, 感谢。
答案 0 :(得分:0)
我能找到的唯一解决方案是升级到xcode 4.2 for snow leopard。我没有意识到xcode 4.2是雪豹的选择。不过确实如此。上面的代码立即工作,xcode 4.2没有任何变化。