【发布时间】:2015-06-07 08:05:27
【问题描述】:
我使用 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"
【问题讨论】:
-
您是否添加了桥接头以将 Ensembles Objective-C 文件导入到 swift 中?
-
是的,我更新到上面显示了
-
如果 Swift 中的 Ensembles 不起作用,有人可以提出替代解决方案吗?我正在尝试将数据保存到 icloud,并与多个设备同步。核心数据会很好,但不是 100% 需要。
-
这是一个 swift 示例,它可能对您有所帮助github.com/oskarirauta/EnsembleExample - 我即将开始使用 swift 将 Ensembles 添加到我的应用程序中,希望一切顺利,您最终让它工作了吗?
标签: ios swift core-data icloud ensembles