2015-10-25 21 views
9

sto ottenendo Use of undeclared identifier per ogni oggetto che uso FacebookFacebook SDK Swift - Uso di identificatore non dichiarato

A seguito di questo tutorial: TUTORIAL: HOW TO SHARE IN FACEBOOK SDK 4.1.X FOR SWIFT

Ma ho il seguente errore:

enter image description here

Ho aggiunto il framework di Facebook tramite cocoapods:

pod 'FBSDKCoreKit' 
pod 'FBSDKShareKit' 

Ed è stato installato con successo

enter image description here

ho aggiunto colmare intestazione

#ifndef Bridging_Header_h 
#define Bridging_Header_h 

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

#endif /* Bridging_Header_h */ 

L'intestazione ponte è collegata:

enter image description here

.210

Ho configurato il mio .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> 

Ecco il codice:

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

ha fatto si esegue pod installare o provare a eseguire di nuovo –

+0

@OmkarGuhilot ho fatto. Ha funzionato bene. I framework sono nel mio progetto Pod – Luda

+0

Quindi è risolto e ha risolto eseguendo di nuovo l'installazione di pod? –

risposta

9

Se si utilizza Baccelli e il progetto è su Swift non è necessario importare le intestazioni da baccelli di Bridging_Header_h E 'suficient di importare necessario SDK per voi lima rapida come:

import FBSDKCoreKit 
import FBSDKLoginKit 
import FBSDKShareKit 
+0

Mi hai salvato !!!!!!! – Luda

+0

Questo è vero. Inoltre, puoi andare avanti e persino iniziare una variabile per le classi. Bella cattura Lurie. – Xrait

5

Il primo passo è creare Podfile, ad esempio:

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

Salvare il file e installare o aggiornare pod per comando:

pod install/pod update 

Successivamente, si dovrebbe aggiungere nel quadro delle impostazioni generali:

enter image description here

+0

Ho aggiunto i framework in cui hai suggerito, ma non è d'aiuto :(http://i65.tinypic.com/20l1idk.png – Luda

Problemi correlati