问题描述
我有一个快速的动态框架,当前正在链接到用Objective C编写的另一个框架.这行得通,但是很烦人,因为Objective C框架实际上只有2个文件,我想知道是否有办法实现这一目标进入我的快速框架.
I have a dynamic framework in swift that currently is linking in another framework that is written in Objective C. This works but its annoying because the Objective C framework really only 2 files and I was wondering if there is a way to bring this into my swift framework.
如果这是一个应用程序,我将使用 Bridging-Header ,但这在Swift框架中不受支持.
If this was an application I'd user Bridging-Header but that is not supported inside a swift framework.
我的框架称为 GDL90 ,仅包含快速文件.
My framework is called GDL90 and consists of only swift files.
我的Objective-C框架包括:
My Objective-C framework consists of:
-
GeoidCalculator.h
-
GeoidCalculator.m
-
EGM96
(数据文件) -
CORCOEF
(数据文件)
GeoidCalculator.h
GeoidCalculator.m
EGM96
(data file)CORCOEF
(data file)
真的很简单-对吗?所以我想看看是否有一种方法可以将此代码添加到我的swift项目中.
Real simple - right? So I wanted to see if there was a way to just add this code into my swift project.
我添加了文件并得到警告在框架模块'GDL90'中包含非模块化标头
I added my file an get the warning Include of non-modular header inside framework module 'GDL90'
好吧,那不是骰子.
我认为我需要制作一个模块映射文件.
I figured I needed to make a module map file.
因此,我创建了一个名为 $ {SRCROOT}/GDL90/EGM96
的目录,并在其中创建了 EGM96.module.modulemap
So I made a directory called ${SRCROOT}/GDL90/EGM96
and inside I created EGM96.module.modulemap
module EGM96 {
header "GeoidCalculator.h"
export *
}
然后在我的一个快捷文件中,有一个 import EGM96
似乎找不到.
And then in one of my swift files i have import EGM96
which doesn't seem to be found.
在我的构建设置中,我有:
In my build settings i have:
定义模块
已打开,我从我的模块映射文件项目
Define Modules
turned on and I'm pointing to the modulemap
file from my Module Map File item
我错过了什么吗?
推荐答案
如果正确创建内部框架,则不需要模块映射文件:
You do not need the modulemap files if create internal framework correctly:
- 在EGM96项目下创建新的框架目标"EGM96":
- 转到GDL90项目->添加新目标-> Cocoa Touch框架
- 输入名称并选择Objective-C作为语言
将Objective-с文件和EGM96的其他来源添加到新目标.
Add objective-с files and other sources of EGM96 to new target.
将GeoidCalculator.h添加为公共标头:
Add GeoidCalculator.h as public header:
- 将GeoidCalculator.h标头的目标成员资格从项目"更改为公共"
- 将标题导入名为EGM96.h的伞形文件
- 确保伞式标头EGM96.h对于EGM96目标是公开的.
导入EGM96
这篇关于澄清了将目标C代码添加到快速动态框架中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!