使用cocoapod和use_frameworks找不到'FBSDKCoreKit / FBSDKCoreKit.h'文件

时间:2017-03-24 09:55:18

标签: ios objective-c cocoapods facebook-sdk-4.x

我在Facebook SDK项目中使用cocoapods安装了objective-c。这就是我在pod文件中添加它的方式

use_frameworks!
  pod 'Bolts'
  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'
  pod 'FBSDKShareKit'

问题是构建失败的原因是:'FBSDKCoreKit/FBSDKCoreKit.h' file not found。我搜索了一下,发现如果在pod文件中添加了use_frameworks!,则必须在pod "Bolts";之前添加pod "FBSDKCoreKit";(来自facebook documentation)。这就是我所做的,但它不起作用。我也尝试清理项目,并使用此命令rm -rf ~/Library/Developer/Xcode/DerivedData但也没有任何结果。 谁能告诉我他的问题在哪里?

修改

当我删除use_frameworks!时 这是我在错误

中得到的
ld: warning: directory not found for option '-L/Users/userName/Library/Developer/Xcode/DerivedData/myProject/Build/Products/Debug-iphonesimulator/Bolts' 
ld: warning: directory not found for option '-L/Users/userName/Library/Developer/Xcode/DerivedData/myProject/Build/Products/Debug-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option '-L/Users/userName/Library/Developer/Xcode/DerivedData/myProject/Build/Products/Debug-iphonesimulator/FBSDKLoginKit'
ld: warning: directory not found for option '-L/Users/userName/Library/Developer/Xcode/DerivedData/myProject/Build/Products/Debug-iphonesimulator/FBSDKShareKit'

1 个答案:

答案 0 :(得分:0)

删除YourPod文件因为您正在使用""和半冒号并添加这些pod文件它将起作用

pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'FBSDKCoreKit'

这些框架工作导入

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

Appdelegate.m

  -(BOOL)application:(UIApplication *)application    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
  {                      

  [[FBSDKApplicationDelegate sharedInstance] application:application
                         didFinishLaunchingWithOptions:launchOptions];
  }

 -(BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url**strong text** sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation
  {

      return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                      openURL:url
                                         sourceApplication:sourceApplication
                                                   annotation:annotation];
 }