报错Using bridging headers with mo

2023-03-27  本文已影响0人  runsuc

Using bridging headers with module interfaces is unsupported

Command SwiftDriver emitted errors but did not return a nonzero exit code to indicate failure

新xcode中OC和swift混编使用了Bridging-Header会出现如上报错,虽然不影响运行,但是影响对其他错误的判断,要去掉这个报错就要去掉Bridging-Header的使用,使用module.modulemap来引入头文件。步骤如下:

1.创建module.modulemap文件,引入到项目中

2.在module.modulemap中添加如下:

module ChangeBridge {

    header "ViewController.h"

    export*

}

ChangeBridge是模块名,ViewController.h是swift要用到的OC类头文件。

3.在build setting中找到Search paths下面的Import Paths,添加$(SRCROOT)/项目名

4. 在需要使用ViewController的swift类中importChangeBridge

5.最后把Bridging-Header文件删除,build setting中的路径也要删除。

6.重新运行就没有报错了

上一篇下一篇

猜你喜欢

热点阅读