此文章已經過期 SDK v4.0.1 之後變不再有此問題
這是一個在編譯時都沒甚麼徵兆,在上傳到 iTunes Connect 檢查才會冒出的警告。
雖然只是警告而非錯誤,怕審核不通過,所以還是處理一下。(好像也有人選擇註記在審核的欄位裡)
The app references non-public selectors in Payload/{Appname}.app/{App name]}: id
花了許多時間才發現是 Facebook SDK 惹的禍,原因是裡面的 property 名稱使用了保留字 id 造成的。
這問題好像存在很久了,只是 Facebook 一直沒去修正。
例如 FBGraphUser.h 這檔案打開來看...
1 2 3 4 5 | @protocol FBGraphUser<FBGraphObject> ... @property (retain, nonatomic ) NSString * id ; ... @end |
這樣的檔案不只一個,最簡單的修改方法就是用 [user objectForKey:@"id"] 或 user[@"id"] 來取代原來的 user.id。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* * Callback for session changes. */ - ( void )sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:( NSError *)error { switch (state) { case FBSessionStateOpen: if (!error) { // We have a valid session //NSLog(@"User session found"); [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary <FBGraphUser> *user, NSError *error) { if (!error) { self .loggedInUserID = [user objectForKey: @"id" ]; self .loggedInSession = FBSession.activeSession; } }]; } break ; case FBSessionStateClosed: case FBSessionStateClosedLoginFailed: [FBSession.activeSession closeAndClearTokenInformation]; break ; default : break ; } [[ NSNotificationCenter defaultCenter] postNotificationName:FBSessionStateChangedNotification object:session]; if (error) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Error" message:error.localizedDescription delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil ]; [alertView show]; } } |
這類錯誤警告只要用最後的關鍵字搜尋整個專案大概可以找到要改的地方,只不過以 id 這種前後都可以組很多單字就只能用猜的...