ios - Xcode 8 和 Swift 无法构建 Objective C 模块 'FBSDKLoginKit'

标签 ios swift facebook-sdk-4.x

我在使用 XCode 8 将最新的 Facebook SDK 4.16.0 集成到我的 Swift 3.0 项目时遇到问题。我手动将 Facebook SDK 添加到我的项目 enter image description here

框架搜索路径 enter image description here

我收到一个编译错误“无法构建模块 FBSDKLoginKit”。
Compiling Error

当我导航到 FBSDKLoginKit.h 时,出现错误提示“找不到 FBSDKLoginKit/FBSDKLoginButton.h”文件。 File not found

我搜索并发现这可能相关 Could not build module 'FBSDKCoreKit' For FacebookSDK 4 .我尝试了一些方法,但是没有成功。

感谢您的帮助。谢谢。

最佳答案

我遇到了同样的问题。感谢this link,我能够解决它.该链接实际上对于将我的 swift 项目与 facebook sdk 完全集成非常有用。但是因为这篇文章可能有点过时了,我不得不做一些不同的事情。特别是我的 appdelegate。这是我完成后的样子。

import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
{
    return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options)
}

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 invalidate graphics rendering callbacks. 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 active 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:.
}
}

所以基本上跟随链接会有帮助,但你应该制作你的 appdelegate.swift,特别是 application 函数和 applicationDidBecomeActive 函数看我上面粘贴的样子。

同样在创建桥头文件之后,将其添加到项目build设置中,如下所示。

在链接中它说它应该包括项目的目录,如下所示: projectName/Bridging-Header.h 但当我尝试这样做时,它似乎已经在我的项目目录中查找,所以它最终在 projectName/projectName/Bridging-Header 中查找我的头文件.h 这是一个无效的路径。所以我像上面的截图一样添加了我的。

关于ios - Xcode 8 和 Swift 无法构建 Objective C 模块 'FBSDKLoginKit',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39813908/

相关文章:

ios - 函数 glGenFramebuffers 的隐式声明

iphone - Facebook iOS Safari "Cannot Open Page Error"使用单点登录验证用户时

ios - 为什么需要使用 NSObject?

swift - 我怎样才能让两个球员在触球时都移动?

iOS 应用程序客户等待名单

ios - 应用程序崩溃,我无法找到原因

Swift 在 Playground 生产部门错误

facebook - FBSDKAppInviteContent 提示登录

ios - 如何修复 "Invariant Violation: requireNativeComponent: "RCTFBLoginButton“在 UIManager 中找不到。”?

Android Facebook SDK (4.31.0) - CustomTabLoginMethodHandler 中的 ActivityNotFoundException