11

Use of undeclared identifier使用するすべての Facebook オブジェクトに対して取得しています

このチュートリアルに従ってください: チュートリアル: SWIFT 用の FACEBOOK SDK 4.1.X で共有する方法

しかし、次のエラーがあります。

ここに画像の説明を入力

cocoapods を介して Facebook フレームワークを追加しました。

pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'

そして、無事にインストールされました

ここに画像の説明を入力

ブリッジヘッダーを追加しました

#ifndef Bridging_Header_h
#define Bridging_Header_h

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

#endif /* Bridging_Header_h */

ブリッジング ヘッダーが接続されています。

ここに画像の説明を入力

.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)
4

4 に答える 4

5

最初のステップは、Podfile を作成することです。次に例を示します。

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

ファイルを保存し、コマンドで Pod をインストールまたは更新します。

pod install / pod update

次に、一般設定フレームワークに追加する必要があります。

ここに画像の説明を入力

于 2015-10-30T12:36:50.210 に答える