如何使Swift框架子模块真正私有? [英] How to make a Swift framework submodule really private?

查看:78
本文介绍了如何使Swift框架子模块真正私有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了另一个问题,该问题带来了有关该问题和可能的解决方案的更多详细信息.似乎有一个已知的bug,它是将来需要改进的主题.

I've found another question which brings more details regarding the problem and possible solutions. It seems like there is a known bug which is a subject for future improvements.

基于iOS Swift的目标C类动态框架

我正在Swift中开发一个框架,并且在框架内使用了一些Objective-C代码.到目前为止,我的模块映射如下所示:

I'm developing a framework in Swift and I'm using some Objective-C code inside the framework. So far my module map looks like this:

framework module MyModule {
    umbrella header "MyModule-umbrella.h"

    export *

    explicit module Private {
        header "MyTools.h"
    }
}

我担心的是,MyTools.h中的所有API在框架外部都是可见的:例如,如果您使用Cocoapods安装框架,则您将import MyModule插入应用程序(不是MyModule.Private ),则可以访问MyTools.h,这是不希望的并且是多余的.有什么方法可以使MyTools在框架外部不可见?

My concern is that all the APIs from MyTools.h are visible from outside the framework: for example, if you install the framework using Cocoapods, then you import MyModule into your application (not MyModule.Private), you are able to access MyTools.h which is not desirable and redundant. Is there any way to make MyTools invisible from outside the framework?

PS.我使用Cocoapods分发框架,这是我的podspec(最重要的部分):

PS. I use Cocoapods to distribute the framework, here is my podspec (the most significant part):

s.module_map    = 'Pod/MyModule.modulemap'
s.frameworks    = 'CoreData', 'CoreTelephony', 'SystemConfiguration'
s.resources     = 'Pod/Classes/MessageStorage/*.xcdatamodeld'
s.public_header_files = 'Pod/Classes/**/*.h'
s.private_header_files = 'Pod/Classes/MyTools/**/*.h'
s.source_files  = 'Pod/Classes/**/*.{h,m,swift}'

PSS.我的伞头不导入MyTools.h

PSS. My umbrella header does not import MyTools.h

PSSS.刚刚尝试从主模块中排除标题:

PSSS. Just tried to exclude the header from the main module:

framework module MyModule {
    umbrella header "MyModule-umbrella.h"

    export *
    exclude header "MyTools.h"

    explicit module Private {
        header "MyTools.h"
    }
}

没有运气.

推荐答案

我发现了另一个问题,该问题带来了有关该问题和可能的解决方案的更多详细信息(尽管不起作用).似乎有一个已知的bug,它是将来需要改进的主题.

I found another question which brings more details regarding the problem and possible solutions (which don't work though). It seems like there is a known bug which is a subject for future improvements.

基于iOS Swift的目标C类动态框架

这篇关于如何使Swift框架子模块真正私有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆