没有此类模块“集成"错误-导入用于快速项目的Objective-C框架 [英] No Such Module 'Ensembles' Error - importing objective-c framework to use in swift project
问题描述
我将Ensembles添加到我的Swift项目-在此处找到 https://github.com/drewmccormack/ensembles .我没有为我的应用程序添加iCloud支持并跨设备同步数据的运气,因此希望它能奏效.
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,
- 在Finder中,将Ensembles iOS.xcodeproj项目从 将框架目录放入您的Xcode项目中.
- 在左侧的源列表中选择应用程序的项目根目录,然后选择应用程序的目标.
- 在常规"选项卡中,单击链接"中的+按钮. 框架和库部分.
- 选择libensembles.a库并添加它.
-
选择构建设置"选项卡.找到其他链接器 标志设置,并添加标志-ObjC.
- 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.
- 选择构建阶段"选项卡. 打开目标依赖关系,然后单击+按钮.
- 找到 集成Resources iOS产品,并将其添加为依赖项.
- 在源列表中打开Ensembles iOS.xcodeproj项目,然后打开产品"组.
- 将Ensembles.bundle产品拖到副本"中 应用程序的捆绑资源构建阶段.
- 在预编译的头文件或使用Ensembles的任何文件中添加以下导入.
- 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.
这是我遇到问题的第10步.我是否必须创建一个桥接标头,或者只是将框架导入到我的swift文件中?
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 ?
这就是我在CoreDataStack.swift
文件
import UIKit
import CoreData
import Ensembles
class CoreDataStack: NSObject, CDEPersistentStoreEnsembleDelegate {
}
这给了我错误;
没有这样的模块合奏"
No such module 'Ensembles'
我尝试通过执行以下操作来创建桥接头;
I tried creating a bridging header by doing the following;
- 添加新的头文件
- 导入乐团
这就是它的样子;
#ifndef Header_h
#define Header_h
#import <Ensembles/Ensembles.h>
#endif /* Header_h */
但是还是没有运气,有人尝试导入要与我的swift项目一起使用的框架时,有人知道我出了什么问题吗?
But still no luck, does anybody know where I am going wrong when trying to import the framework to use with my swift project ?
推荐答案
创建桥接标头时,无需使用import.
When creating a bridging header you do not need to use import.
但是,我认为您可能没有正确添加桥接头,请转到文件,新建,文件,添加Objective-C文件,然后会弹出一个对话框,询问您是否要创建桥接头.添加两个文件,但删除Objective-C文件并保留桥接头.
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.
然后像这样将ensembles框架导入到桥接头中.
Then import the ensembles framework to the bridging header like so.
#import <Ensembles/Ensembles.h>
成功创建桥接文件时,您无需将框架导入到swift文件中,并且该框架在整个项目中都可用.有关更多信息,请参见此帖子-连接目标C到Swift iOS 8应用的框架(解析框架)
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)
这篇关于没有此类模块“集成"错误-导入用于快速项目的Objective-C框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!