I am add Ensembles to my Swift project - found here https://github.com/drewmccormack/ensembles. I have had no luck adding iCloud support to my app and syncing data across devices so hoping this will work.
I have followed the following instructions for adding the framework to my app,
- In Finder, drag the Ensembles iOS.xcodeproj project from the Framework directory into your Xcode project.
- Select your App's project root in the source list on the left, and then select the App's target.
- In the General tab, click the + button in the Linked Frameworks and Libraries section.
- Choose the libensembles.a library and add it.
Select the Build Settings tab. Locate the Other Linker Flags setting, and add the flag -ObjC.
This is how it looks in my project, I am unsure if i have done this step right.
- Select the Build Phases tab. Open Target Dependencies, and click the + button.
- Locate the Ensembles Resources iOS product, and add that as a dependency.
- Open the Ensembles iOS.xcodeproj project in the source list, and open the Products group.
- Drag the Ensembles.bundle product into the Copy Bundle Resources build phase of your app.
- Add the following import in your precompiled header file, or in any files using Ensembles.
It is step 10 that I am having problems with. Do I have to create a bridging header or just import the framework into my swift files ?
This is how I am importing within my CoreDataStack.swift
file
import UIKit
import CoreData
import Ensembles
class CoreDataStack: NSObject, CDEPersistentStoreEnsembleDelegate {
}
This gives me the error;
No such module 'Ensembles'
I tried creating a bridging header by doing the following;
- Add new header file
- Import Ensembles
This is how that looks;
#ifndef Header_h
#define Header_h
#import <Ensembles/Ensembles.h>
#endif /* Header_h */
But still no luck, does anybody know where I am going wrong when trying to import the framework to use with my swift project ?
When creating a bridging header you do not need to use import.
However I don't think you may be adding a bridging header correctly, go to, file, new, file, add a objective-C file and a dialog should pop up asking if you want to create a bridging header. Add both files but delete the objective-C file and keep the bridging header.
Then import the ensembles framework to the bridging header like so.
When creating a bridging file successfully you should not need to import the framework in your swift files and it should be available throughout your project. See this post for more information - Connect Objective C framework to Swift iOS 8 app (Parse framework)