3

I successfully added Ensembles using pods and compiled with no errors. Now I'm adding code to my AppDelegate.swift file. Build fails with

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)

I think the relevant code in AppDelegate.swift is

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
}

My error is probably right in front of me, but I don't know.

my Bridging-Header.h looks like

#import <Foundation/Foundation.h>
#import <Ensembles/Ensembles.h>
#import "DropboxSDK.h"
#import "CDEDropboxCloudFileSystem.h"
Mark
  • 555
  • 6
  • 17
  • Have you added the bridging header to import the Ensembles Objective-C files into swift? – sbarow Jun 07 '15 at 08:42
  • yes, I updated to show it above – Mark Jun 07 '15 at 15:24
  • If Ensembles in Swift doesn't work, can some one suggest an alternative solution? I'm trying to save data to icloud, and sync it with multiple devices. Core data would be nice, but not 100% required. – Mark Jun 25 '15 at 07:24
  • Here's an example in swift it may help you https://github.com/oskarirauta/EnsembleExample - I am about to start adding Ensembles to my app using swift and hope it all goes well, did you get it to work in the end? – RileyDev Mar 30 '16 at 21:44

1 Answers1

0

Most likely your bridging header is not read.

Under Build Settings, make sure the Objective-C Bridging Header build setting under Swift Compiler - Code Generation has a path to the header. The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you should not need to modify this setting.

Depending on your setup, maybe you also need to import the framework in your Swift file.

import Ensembles
Mundi
  • 79,884
  • 17
  • 117
  • 140
  • When I add 'import Ensembles' I get a "No such module 'Ensembles'" error. – Mark Jun 08 '15 at 14:40
  • I have other entries in my bridging header that are being read and used like #import "SWRevealViewController.h" – Mark Jun 08 '15 at 17:10
  • other .h files are working in the bridging header. If you're asking about "import Ensembles.h" in my AppDelegate.swift file, it has the error of "No such module 'Ensembles.h'" – Mark Jun 09 '15 at 20:35
  • Perhaps you do not need to import. As stated, this depends on your setup - it depends on how Ensembles is built. – Mundi Jun 09 '15 at 21:51
  • 1
    yeah, it doesn't change the errors I getting if I try to import it there or not. Unfortunately Ensembles doesn't have any Swift documentation or code examples for a new users like me. – Mark Jun 09 '15 at 23:38