Xcode 8 和 Swift 无法构建 Objective C 模块'FBSDKLoginKit'
Posted
技术标签:
【中文标题】Xcode 8 和 Swift 无法构建 Objective C 模块\'FBSDKLoginKit\'【英文标题】:Xcode 8 and Swift Could not build Objective C module 'FBSDKLoginKit'Xcode 8 和 Swift 无法构建 Objective C 模块'FBSDKLoginKit' 【发布时间】:2016-10-02 04:36:17 【问题描述】:我在使用 XCode 8 将最新的 Facebook SDK 4.16.0 集成到我的 Swift 3.0 项目中时遇到问题。我手动将 Facebook SDK 添加到我的项目中
框架搜索路径
我收到一个编译错误,提示“无法构建模块 FBSDKLoginKit”。
当我导航到 FBSDKLoginKit.h 时,错误提示“找不到 FBSDKLoginKit/FBSDKLoginButton.h”文件。
我搜索并发现这可能与 Could not build module 'FBSDKCoreKit' For FacebookSDK 4 相关。我尝试了一些方法,但都没有成功。
感谢您的帮助。谢谢。
【问题讨论】:
【参考方案1】:我遇到了同样的问题。感谢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
函数看起来像我上面粘贴的那样。
同样在创建桥头文件后,将其添加到项目构建设置中看起来像这样。
在链接中它说它应该包括项目的目录,如下所示:
projectName/Bridging-Header.h
但是当我尝试这样做时,它似乎已经在从我的项目目录中查找,所以它最终在 projectName/projectName/Bridging-Header.h
寻找我的头文件,这是一个无效的路径。所以我像上面的截图一样添加了我的。
【讨论】:
以上是关于Xcode 8 和 Swift 无法构建 Objective C 模块'FBSDKLoginKit'的主要内容,如果未能解决你的问题,请参考以下文章
目标 C 项目中的 Xcode 8.3 Swift 版本错误 (SWIFT_VERSION)
无法正确地自动调整自动布局和堆栈视图(Swift 3、Xcode 8)