gpt4 book ai didi

facebook - 找不到与 Parse 一起使用的“FacebookSDK/FacebookSDK.h”文件

转载 作者:行者123 更新时间:2023-11-30 14:06:40 25 4
gpt4 key购买 nike

我正在使用 Parse 和 Facebook,但遇到以下 2 个错误:

  1. 'FacebookSDK/FacebookSDK.h' file not found

  2. Failed to import bridging header

我已经将 ParseFacebookUtilsV4/PFFacebookUtils.hParseFacebookUtils/PFFacebookUtils.h 导入到我的桥接 header 中,因为我正在使用 Swift 做所有事情。

但是当我刚刚使用 Parse 时一切正常,所以我认为问题仅出在 FacebookSDK 上。

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

  1. 这是我的应用程序委托(delegate)

    导入UIKit

    @UIApplicationMainAppDelegate 类:UIResponder、UIApplicationDelegate {

    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)
    }

    }

  2. View Controller

    导入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>

4 我的桥接文件

#import "FBSDKCoreKit.h"
#import "Parse.h"

最佳答案

Facebook SDK Swift 集成

与此任务相关的众多步骤之一可能出了问题。如果您从一个新项目重新开始,您可能会发现您错过了哪一步。请按照下面的acebook iOS 集成教程进行操作。

创建一个全新的 Xcode 项目

Xcode > 文件 > 项目... > 单 View 应用程序 > 下一步 > 产品名称 SO-32302877 ,语言 Swift> 下一步 > 创建。

添加 Pod

在终端中:

cd SO-32302877
pod init

并让你的Podfile像这样:

platform :ios, '8.0'
target 'SO-32302877' do
pod 'FBSDKCoreKit'
end

如果尚未完成,请关闭 Xcode 项目。在终端中,运行:

pod install

导入SDK

打开SO-32302877.xcworkspace 。创建桥接 header 。最简单的方法是添加和删除 Obj-C 文件。在 Xcode > 导航器中,选择 SO-32302877组,Xcode > 文件 > 新建 > 文件... > Cocoa Touch 类 > 下一步 > 类:ObjC,语言:Objective-C> 下一步 > 创建。

enter image description here

您现在可以选择并删除 ObjC.hObjC.m来自 Xcode 的文件并移至垃圾箱。您现在拥有 SO-32302877-Bridging-Header.h ,目标 SO-32302877 build设置已正确设置。在 SO-32302877-Bridging-Header.h ,添加:

#import "FBSDKCoreKit.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 上构建、链接、运行和测试。

<小时/>

要下载完整项目,请搜索 SO-32302877在《Swift 食谱》中。

关于facebook - 找不到与 Parse 一起使用的“FacebookSDK/FacebookSDK.h”文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32302877/

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