ios - 在OC项目中导入swift框架的问题。
怪我咯
怪我咯 2017-04-18 09:47:57
0
6
470

创建了一个oc项目,使用cocoapods导入了一个swift编写的框架(SwiftTheme)
根据这个框架的oc Demo,正常情况应该是会自动生成一个"项目名-swift.h"的文件并且import进oc项目才可以使用。
但在我的项目里#import"项目名-swift.h"却提示找不到,显示一个大大的问号。


除非自己手动new一个swift文件,#import"项目名-swift.h"就会成功.

ps:让我改Defines Module、Product Module Name之流的就不用回答了,我会用百度,不管用才来这儿问的。

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(6)
洪涛

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

阿神

I am also from Baidu. This is what I summarized before. Researched: http://mog.pub/

刘奇

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.

小葫芦

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?

阿神

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.

大家讲道理

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template