创建了一个oc项目,使用cocoapods导入了一个swift编写的框架(SwiftTheme)
根据这个框架的oc Demo,正常情况应该是会自动生成一个"项目名-swift.h"的文件并且import进oc项目才可以使用。
但在我的项目里#import"项目名-swift.h"
却提示找不到,显示一个大大的问号。
除非自己手动new一个swift文件,#import"项目名-swift.h"
就会成功.
ps:让我改Defines Module、Product Module Name之流的就不用回答了,我会用百度,不管用才来这儿问的。
PHP中文网2017-04-18 09:49:57
Using swift in oc is a little more troublesome. Do I need to set the project name or something? Forgot. Baidu has it. You search for swift oc mixed code
阿神2017-04-18 09:49:57
I am also from Baidu. This is what I summarized before. Researched: http://mog.pub/
怪我咯2017-04-18 09:49:57
In fact, it can be like this: @import xxSDK;
另外,你的写法应该是 #import <xxSDK/xxSDK-Swift.h>
,
用 <xx/xx.h>
instead of quotation marks
The legend is a pure swift framework written by me.
高洛峰2017-04-18 09:49:57
ps: If you want me to change the Defines Module, Product Module Name, etc., you don’t need to answer. I can use Baidu. That’s why I came here to ask if it doesn’t work.
After making the change, use command+click with the left mouse button to enter the "project name-swift.h". Have you tried it?
阿神2017-04-18 09:49:57
Solved, no need for cocoapods, just drag the third-party framework source file into the project and it will be automatically generated"项目名-swift.h"
.
Although it works, I still don’t understand why it can’t be generated using cocoapods. No matter.
大家讲道理2017-04-18 09:49:57
The premise of import "project name-swift.h" must be in the same module. If it is not in the same module, the target namespace must be added in front, in the form of #import <xxSDK/xxSDK-Swift. h>.
You are using pod. The Alomafire introduced by pod is in a different target, so the following method is effective.