Wrong Module-Swift.h header is generated with import to itself

点点圈 提交于 2021-01-28 19:13:57

问题


So I am mixing swift and objc everywhere. I have development pod called Renetik. It has some extensions written in swift but it's mostly objective c code. Now, I wrote some class and used it in main project fine and wanted to move it to Renetik development pod. When I do it somehow in Renetik-Swift.h wrong import is generated and project won't compile.

#import <Renetik/Renetik.h>

Then I experimented a lot. And found out that wrong import is generated when I actually return from swift class function type defined in pod itself. It is happening just when I try to make it in Development Pod where is mostly objective-c. Other swift extension and classes works juts when I try to modify some class to return objc class defined in pod itself.

I will write example when everything is OK. This compiles fine and I can call function testMe from main project:

@objc public class ReplaceMe: NSObject {
    @objc public func testMe() {
        let variable = CSResponse<NSObject>()
        variable.cancel()
    }
}

Just this small change and wrong header is generated as I stated before:

@objc public class ReplaceMe: NSObject {
    @objc public func testMe() -> CSResponse<NSObject> {
        let variable = CSResponse<NSObject>()
        variable.cancel()
        return variable
    }
}

I use use_frameworks! in podfile as use_modular_headers! don't work for other reasons. I m able to setup branch in Github project where this happens as this is open source.


回答1:


So it seems only not hack possibility is to create other pod just for Swift files. Define in podspec dependency to released verison, and in host application podfile add dependencies with :path => .



来源:https://stackoverflow.com/questions/54621996/wrong-module-swift-h-header-is-generated-with-import-to-itself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!