3

我使用 pod 成功添加了 Ensembles,并且编译时没有出现错误。现在我将代码添加到我的 AppDelegate.swift 文件中。构建失败

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CDEPersistentStoreEnsemble", referenced from:
      __TMaCSo26CDEPersistentStoreEnsemble in AppDelegate.o
  "_CDEMonitoredManagedObjectContextDidSaveNotification", referenced from:
      __TFC8nicepal11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb in AppDelegate.o
  "_OBJC_CLASS_$_CDEICloudFileSystem", referenced from:
      __TMaCSo19CDEICloudFileSystem in AppDelegate.o
  "_CDEICloudFileSystemDidDownloadFilesNotification", referenced from:
      __TFC8nicepal11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我认为 AppDelegate.swift 中的相关代码是

var ensemble:CDEPersistentStoreEnsemble?
var ensembleCloudFileSystem:CDECloudFileSystem?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CDEPersistentStoreEnsembleDelegate {

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let store_url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("nicepal.sqlite")
        let modelURL = NSBundle.mainBundle().URLForResource("nicepal", withExtension: "momd")!

    ensembleCloudFileSystem = CDEICloudFileSystem(
        ubiquityContainerIdentifier: "something"
    )

    ensemble = CDEPersistentStoreEnsemble(
        ensembleIdentifier: "IDENTIFIER",
        persistentStoreURL: store_url,
        managedObjectModelURL:modelURL,
        cloudFileSystem:ensembleCloudFileSystem
    )

    ensemble?.delegate = self
    NSNotificationCenter.defaultCenter().addObserver(self, selector: "syncWithCompletion:", name: CDEMonitoredManagedObjectContextDidSaveNotification, object: nil)
    NSNotificationCenter.defaultCenter().addObserver(self, selector: "syncWithCompletion:", name: CDEICloudFileSystemDidDownloadFilesNotification, object: nil)
    return true
}

我的错误可能就在我面前,但我不知道。

我的 Bridging-Header.h 看起来像

#import <Foundation/Foundation.h>
#import <Ensembles/Ensembles.h>
#import "DropboxSDK.h"
#import "CDEDropboxCloudFileSystem.h"
4

1 回答 1

0

很可能您的桥接头没有被读取。

在 Build Settings 下,确保 Swift Compiler - Code Generation 下的 Objective-C Bridging Header 构建设置具有指向标头的路径。该路径应该与您的项目相关,类似于在 Build Settings 中指定 Info.plist 路径的方式。在大多数情况下,您不需要修改此设置。

根据您的设置,也许您还需要在 Swift 文件中导入框架。

import Ensembles
于 2015-06-08T08:39:00.130 回答