2015-10-25 19 views
9

Tôi nhận Use of undeclared identifier cho mọi đối tượng Facebook tôi sử dụngFacebook SDK Swift - Sử dụng định danh chưa được khai báo

Tiếp theo hướng dẫn này: TUTORIAL: HOW TO SHARE IN FACEBOOK SDK 4.1.X FOR SWIFT

Nhưng tôi đã có những lỗi sau:

enter image description here

Tôi đã thêm khuôn khổ Facebook qua cocoapods:

pod 'FBSDKCoreKit' 
pod 'FBSDKShareKit' 

Và nó đã được cài đặt thành công

enter image description here

Tôi đã thêm cầu nối tiêu đề

#ifndef Bridging_Header_h 
#define Bridging_Header_h 

#import <FBSDKCoreKit/FBSDKCoreKit.h> 
#import <FBSDKShareKit/FBSDKShareKit.h> 

#endif /* Bridging_Header_h */ 

Phần header bắc cầu được kết nối:

enter image description here

.210

Tôi đã cấu hình plist tôi

<key>CFBundleURLTypes</key> 
    <array> 
     <dict> 
      <key>CFBundleURLSchemes</key> 
      <array> 
       <string>fb*****</string> 
      </array> 
     </dict> 
    </array> 
    <key>FacebookAppID</key> 
    <string>*****</string> 
    <key>FacebookDisplayName</key> 
    <string>*****</string> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>facebook.com</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> 
      </dict> 
      <key>fbcdn.net</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> 
      </dict> 
      <key>akamaihd.net</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> <true/> 
       <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> 
      </dict> 
     </dict> 
    </dict> 

Đây là mã:

let content : FBSDKShareLinkContent = FBSDKShareLinkContent() 
     content.contentURL = NSURL(string: "<INSERT STRING HERE>") 
     content.contentTitle = "<INSERT STRING HERE>" 
     content.contentDescription = "<INSERT STRING HERE>" 
     content.imageURL = NSURL(string: "<INSERT STRING HERE>") 

     let button : FBSDKShareButton = FBSDKShareButton() 
     button.shareContent = content 
     button.frame = CGRectMake((UIScreen.mainScreen().bounds.width - 100) * 0.5, 50, 100, 25) 
     self.view.addSubview(button) 
+0

bạn đã chạy pod install hoặc thử chạy lại lần nữa –

+0

@OmkarGuhilot Tôi đã làm. Nó hoạt động tốt. Các khung công tác này nằm trong dự án Pods của tôi – Luda

+0

Vì vậy, nó được giải quyết và nó đã giải quyết bằng cách chạy pod cài đặt một lần nữa? –

Trả lời

9

Nếu bạn sử dụng Pods và dự án của bạn là trên Swift bạn không cần phải nhập khẩu tiêu đề từ vỏ đến Bridging_Header_h Đó là suficient để nhập cần thiết SDK cho bạn nhanh chóng tập tin như:

import FBSDKCoreKit 
import FBSDKLoginKit 
import FBSDKShareKit 
+0

Bạn đã lưu tôi !!!!!!! – Luda

+0

Điều này đúng. Ngoài ra, bạn có thể đi đầu và thậm chí bắt đầu một biến cho các lớp học.Làm đẹp bắt Lurie. – Xrait

5

Bước đầu tiên là tạo Podfile, ví dụ:

use_frameworks! 
pod 'ChameleonFramework/Swift' 
pod 'GBDeviceInfo' 

Lưu tập tin và cài đặt hoặc cập nhật nhóm theo lệnh:

pod install/pod update 

Tiếp theo, bạn nên thêm trong khuôn khổ thiết lập chung:

enter image description here

+0

Tôi đã thêm các khung nơi bạn sugested, nhưng nó không giúp được gì: (http://i65.tinypic.com/20l1idk.png – Luda

Các vấn đề liên quan