gpt4 book ai didi

ios - 我们可以限制 Swift 生成的接口(interface)只能在 Xcode 中从模块访问吗?

转载 作者:行者123 更新时间:2023-11-28 07:30:45 25 4
gpt4 key购买 nike

案例

一个模块(带有模块映射文件的静态库)在 iOS 应用程序代码库中具有混合代码(Objective-C + Swift)。Swift 代码只需要从模块中使用,所以所有需要的接口(interface)都是内部

文档 here

Because the generated header is part of the framework’s public interface, only declarations marked with the public or open modifier appear in the generated header for a framework target. Methods and properties that are marked with the internal modifier and declared within a class that inherits from an Objective-C class are accessible to the Objective-C runtime. However, they're inaccessible at compile time and don't appear in the generated header for a framework target.

在 XCode 上,我能够成功编译项目,但在我们使用 BUCK 的 CI 机器上构建失败,因为它无法在模块 中找到从 Objective C 代码内部定义的 Swift 方法。有效的修复方法是公开这些方法。

我的疑问:

  • 这是 XCode 中的错误吗,因为文档暗示我们要从 Objective C 使用的 Swift 方法必须是公开的?
  • 我们是否需要将模块内所需的所有接口(interface)标记为public,即使我们在模块内使用它?

Generated header is part of the framework’s public interface

  • 即使生成的头文件没有在 modulemap 中声明(或者伞头),它会保留框架的公共(public)接口(interface)吗?如果 Swift 仅在模块内使用而我不使用怎么办想将其暴露给其他模块?

最佳答案

不,目前这是不可能的。我说它与 XCode 一起工作是错误的。有一个 enhancement在 Swift 存储库中记录了它的请求。

关于ios - 我们可以限制 Swift 生成的接口(interface)只能在 Xcode 中从模块访问吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54805494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com