找不到“FacebookSDK/FacebookSDK.h”文件可用于解析

找不到“FacebookSDK/FacebookSDK.h”文件可用于解析,facebook,swift,parse-platform,Facebook,Swift,Parse Platform,我正在使用Parse和Facebook。我有以下两个错误: 找不到“FacebookSDK/FacebookSDK.h”文件 无法导入桥接标头 我已经将ParseFacebookUtilsV4/PFFacebookUtils.h和ParseFacebookUtils/PFFacebookUtils.h导入到我的桥接头中,因为我正在使用Swift执行所有操作 但是当我刚刚使用Parse时,一切都很好,所以我认为问题只存在于FacebookSDK 安装pod文件并启动项目后,以下是我的文件: 这是我

我正在使用Parse和Facebook。我有以下两个错误:

找不到“FacebookSDK/FacebookSDK.h”文件

无法导入桥接标头

我已经将ParseFacebookUtilsV4/PFFacebookUtils.h和ParseFacebookUtils/PFFacebookUtils.h导入到我的桥接头中,因为我正在使用Swift执行所有操作

但是当我刚刚使用Parse时,一切都很好,所以我认为问题只存在于FacebookSDK

安装pod文件并启动项目后,以下是我的文件:

这是我的应用程序代理

导入UIKit

@UIApplicationMain 类AppDelegate:UIResponder、UIApplicationLegate{

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    Parse.enableLocalDatastore()

    // Initialize Parse.
    Parse.setApplicationId(“MY_APLLICATION_ID”,
        clientKey: "MY_APLLICATION_KEY")
    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
    // [Optional] Track statistics around application opens.
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)



    return true
}

func applicationWillResignActive(application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    FBSDKAppEvents.activateApp()
}

func applicationWillTerminate(application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

func application(application: UIApplication,
    openURL url: NSURL,
    sourceApplication: String?,
    annotation: AnyObject?) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application,
            openURL: url,
            sourceApplication: sourceApplication,
            annotation: annotation)
}
}

视图控制器

导入UIKit

类ViewController:UIViewController{

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    var permissions = ["public_profile"]

    PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
        (user: PFUser?, error: NSError?) -> Void in
        if let user = user {
            if user.isNew {
                println("User signed up and logged in through Facebook!")
            } else {
                println("User logged in through Facebook!")
            }
        } else {
            println("Uh oh. The user cancelled the Facebook login.")
        }
    }

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
}

普利斯特

我加了这个

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>MY_APP_KEY</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>MY_APP_KEY</string>
    <key>FacebookDisplayName</key>
    <string>MY_APP_NAME</string>
FacebookSDK快速集成 这项任务涉及的许多步骤中有一个可能出错。如果你重新开始一个新的项目,你可能会发现你错过了哪一步。请遵循下面的Facebook iOS集成教程

创建一个新的Xcode项目 Xcode>文件>项目…>单视图应用程序>下一步>产品名称SO-32302877,语言Swift>下一步>创建

加一个豆荚

在终端:

cd SO-32302877
pod init
并使您的播客文件如下所示:

platform :ios, '8.0'
target 'SO-32302877' do
pod 'FBSDKCoreKit'
end
如果尚未完成,请关闭Xcode项目。在终端中,运行:

pod install
导入SDK 打开SO-32302877.xcworkspace。创建桥接标头。最简单的方法是添加和删除Obj-C文件。在Xcode>Navigator中,选择SO-32302877组,Xcode>File>New>File…>Cocoa Touch Class>Next>Class:ObjC,语言:Objective-C>Next>Create

您现在可以从Xcode中选择并删除ObjC.h和ObjC.m文件,并移动到垃圾箱。现在您有了一个SO-32302877-bridgeing-Header.h,并且正确设置了目标SO-32302877构建设置。 在SO-32302877-Bridgeting-Header.h中,添加:

测试仪器 在Swift实现中,调用:

let token:FBSDKAccessToken = FBSDKAccessToken(
    tokenString: "tokenString",
    permissions: [],
    declinedPermissions: [],
    appID: "appID",
    userID: "userID",
    expirationDate: NSDate(),
    refreshDate: NSDate())
print("\(token)")
在Xcode 7+iOS 8.4上构建、链接、运行和测试

要下载完整的项目,请在Swift Recipes中搜索。

Facebook+Parse+Utils 使用ParseFacebookUtilsV4匹配问题中的代码。我怀疑你正在经历困难,因为有多个不连贯的库

播客文件

SO-32302877-Bridgeting-Header.h

AppDelegate.swift

视图控制器


► 在上查找此解决方案,并在上查找其他详细信息。

您不理解此问题,对吗?你的方式只是如何使用Facebook。导入parse后,我遇到了相同的错误。好的,我再试了一次。现在,一个新的problemFBSDKCoreKit.h文件没有找到,您使用的是哪个Xcode版本,您有最新的Cocoapods吗?如果您修改Podfile,您可能需要rm-rf Pods/Podfile.lock;pod安装,而不仅仅是pod安装。确保关闭Xcode以避免.workspace错误,并清理生成文件夹。仍然没有,我正在尝试。但是仍然没有结果你下载了Swift配方了吗?它是开箱即用的。pod安装有错误吗?您没有提到您在pod文件中使用了ParseFacebookUtilsV4。我怀疑您有多个相互冲突的库。我应该怎么做,我想我无法避免使用ParseFacebookUtilsV4?如果某个答案对您有用,您可能希望勾选此答案对其他人有用,以便让其他人知道。
#import "FBSDKCoreKit.h"
let token:FBSDKAccessToken = FBSDKAccessToken(
    tokenString: "tokenString",
    permissions: [],
    declinedPermissions: [],
    appID: "appID",
    userID: "userID",
    expirationDate: NSDate(),
    refreshDate: NSDate())
print("\(token)")
platform :ios, '8.0'
target 'SO-32302877' do
pod 'FBSDKCoreKit'
pod 'Parse'
pod 'ParseFacebookUtilsV4'
end
#import "FBSDKCoreKit.h"
#import "Parse.h"
#import "PFFacebookUtils.h"
func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions:
                     [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Parse.enableLocalDatastore()
    Parse.setApplicationId("applicationId", clientKey: "clientKey")
    PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions)
    PFAnalytics.trackAppOpened(launchOptions: launchOptions)
    return true
}
let permissions = ["permissions"]
PFFacebookUtils.logInInBackground(withReadPermissions: permissions) {
    (user: PFUser?, error:Error?) in
    if let user = user {
        print("user.isNew \(user.isNew)")
    } else {
        print("!user")
    }
}