gpt4 book ai didi

ios - Facebook SDK Swift - 使用未声明的标识符

转载 作者:IT王子 更新时间:2023-10-29 05:29:52 24 4
gpt4 key购买 nike

我正在为我使用的每个 Facebook 对象使用未声明的标识符

按照本教程: TUTORIAL: HOW TO SHARE IN FACEBOOK SDK 4.1.X FOR SWIFT

但是我遇到了以下错误:

enter image description here

我通过 cocoapods 添加了 Facebook 框架:

pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'

安装成功

enter image description here

我添加了桥接头

#ifndef Bridging_Header_h
#define Bridging_Header_h

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

#endif /* Bridging_Header_h */

桥接头已连接:

enter image description here

我已经配置了我的 .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>

代码如下:

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)

最佳答案

如果您使用 Pods 并且您的项目在 Swift 上,则不需要将 header 从 pods 导入到 Bridging_Header_h将所需的 SDK 导入到您的 swift 文件中就足够了,例如:

import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit

关于ios - Facebook SDK Swift - 使用未声明的标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33328089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com