我使用 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"