![](/img/trans.png)
[英]Facebook Login Swift don't works On Device (But do on IOS Simulator)
[英]Facebook IOS SDK Login works on simulator, not on device
Facebook Login,讓我自己有點位置。
不幸的是,由於我正在做的工作,我只能訪問運行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];
但是我很難確定或不知道為什么。
喜歡一些想法或幫助,謝謝。
我能找到的唯一解決方案是將雪豹升級到xcode 4.2。 我沒有意識到xcode 4.2是雪豹的選擇。 但是,確實如此。 上面的代碼可以立即工作,而xcode 4.2中沒有任何更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.