Lud*_*uda 11 facebook objective-c ios swift bridging-header
我正在Use of undeclared identifier使用我使用的每个Facebook对象
遵循本教程: 教程:如何在FACEBOOK SDK 4.1.X for SWIFT中分享
但我有以下错误:
我通过cocoapods添加了Facebook框架:
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
Run Code Online (Sandbox Code Playgroud)
它已成功安装
我添加了桥接头
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
#endif /* Bridging_Header_h */
Run Code Online (Sandbox Code Playgroud)
桥接头连接:
我已经配置了我的.plist
<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>
Run Code Online (Sandbox Code Playgroud)
这是代码:
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)
Run Code Online (Sandbox Code Playgroud)
Iur*_*nea 13
如果您使用Pod并且您的项目在Swift上,则不需要将标题从pod导入Bridging_Header_h 将所需的SDK导入到swift文件中是足够的,例如:
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
Run Code Online (Sandbox Code Playgroud)
小智 5
第一步是创建Podfile,例如:
use_frameworks!
pod 'ChameleonFramework/Swift'
pod 'GBDeviceInfo'
Run Code Online (Sandbox Code Playgroud)
按命令保存文件并安装或更新pod:
pod install / pod update
Run Code Online (Sandbox Code Playgroud)
接下来,您应该添加一般设置框架:

| 归档时间: |
|
| 查看次数: |
5006 次 |
| 最近记录: |