在 Xcode 6.3 (Swift) 中使用 Parse 和 Facebook 框架编译错误

Compile Error using Parse and Facebook Frameworks in Xcode 6.3 (Swift)

我正在尝试使用 Xcode 6.3 将 Parse 和 Facebook 的 SDK 与我的应用程序集成,但在尝试构建时遇到了这些错误:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FBSDKAppEvents", referenced from:
      __TMaCSo14FBSDKAppEvents in AppDelegate.o
  "_OBJC_CLASS_$_FBSDKApplicationDelegate", referenced from:
      __TMaCSo24FBSDKApplicationDelegate in AppDelegate.o
  "_OBJC_CLASS_$_PFAnalytics", referenced from:
      __TMaCSo11PFAnalytics in AppDelegate.o
  "_OBJC_CLASS_$_PFFacebookUtils", referenced from:
      __TMaCSo15PFFacebookUtils in AppDelegate.o
  "_OBJC_CLASS_$_Parse", referenced from:
      __TMaCSo5Parse in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不知道这是什么意思,但我已经尝试了很多其他解决方案,例如清理、删除 Derived Data 文件夹、检查我所有的框架,但我仍然无法解决问题。如果有人知道如何解决这个问题,我将不胜感激。谢谢你的时间。

编辑 这是我正在使用的桥接-Header.h:

#import <AFNetworking.h>
#import <BDBOAuth1RequestOperationManager.h>
#import <NSDictionary+BDBOAuth1Manager.h>
#import <UIImageView+AFNetworking.h>
#import <UIScrollView+SVInfiniteScrolling.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
#import <Parse/Parse.h>
#import <ParseCrashReporting/ParseCrashReporting.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <Bolts/Bolts.h>

这是 AppDelegate.swift 文件:

import UIKit
import CoreData
import Parse
import FBSDKCoreKit
import FBSDKLoginKit
import Bolts

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

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

    // Type casting in swift is "as Type", you'll need to unwrap optionals however.
    let tabBarController = self.window!.rootViewController as! UITabBarController
    let tabBar = tabBarController.tabBar as UITabBar

    // I prefer to use 0 based labels since the array is 0 based
    let tabBarItem0 = tabBar.items![0] as! UITabBarItem
    let tabBarItem1 = tabBar.items![1] as! UITabBarItem
    let tabBarItem2 = tabBar.items![2] as! UITabBarItem

    // The UIColor method you are using is an initializer in swift
    tabBar.tintColor = UIColor(red: 62.0/255.0, green: 191.0/255.0, blue: 180.0/255.0, alpha: 1.0)

    // UIImage also has an initializer for your situation in swift
    tabBarItem0.selectedImage = UIImage(named: "Discover TabBar Select.pdf")
    tabBarItem1.selectedImage = UIImage(named: "Me TabBar Select.pdf")
    tabBarItem2.selectedImage = UIImage(named: "Settings TabBar Select.pdf")

    //Facebook SDK Setup
    FBSDKApplicationDelegate.sharedInstance()
    Parse.setApplicationId("HxjVTJZ2rZA6qFBl0Xaji9z12HYQmTFPIXhVcfPp", clientKey:"8FJT7KHSmDPZi1AtpFS1GvTw39qevvB0JuimwWdS")

    if let launchOptions = launchOptions {
        PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
    } else {
        PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions([NSObject:AnyObject]())
    }

    // [Optional] Power your app with Local Datastore. For more info, go to
    // https://parse.com/docs/ios_guide#localdatastore/iOS
    Parse.enableLocalDatastore()

    // [Optional] Track statistics around application opens.
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

    return true
}

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

我将最新的 Parse 和 Facebook SDK Frameworks 拖到我的项目中,并通过 "Link Binary with Libraries" 选项卡中的 "Build Phases"节

希望这些附加信息有用。

我也遇到了同样的问题。在我的矿井中,Facebook sdk 4.1。这些是我的步骤:-

1) 转到构建设置

2) 键入 其他链接器标志。因为我正在使用 objective C。所以我点击它并添加两个新值。第一个是 -ObjC,第二个是 $(inherited)。添加这两个值后,您的其他链接器标志将显示为 -ObjC -ObjC -|"Pods-...... 之类的。我正在使用 cocapods .

3) 现在键入 "Allow Non-modular Includes in Framework Modules" 并使用 YES 值。

4) 然后键入“启用模块(C 和 Objective-C),它应该是 YES。

清理并构建您的项目。如果它仍然不适合您,那么请检查您的 Link 二进制库。在 My Mine 中,这些是框架。

Accounts.framework
AddressBook.framework
Foundation.framework
CFNetwork.framework
GoolgeMaps.Framework
Social.framework
CoreData.framework
QuartzCore.framework
Security.framework
CoreLocation.framework
CoreGraphics.framework
UIKit.framework

请试试看谢谢

将 Parse 更新到版本 1.7.4 后,此问题自行解决。希望这可以帮助其他遇到与我相同问题的人!

解决我的问题的方法是将 Facebook 框架添加到链接框架和库中。请注意,这未包含在 Facebook 登录文档中。