ios - 内部类存在于混合框架的自动生成的 header 中

标签 ios objective-c swift ios-frameworks

根据有关内部访问修饰符的 Apple 文档:

 For framework targets, only declarations with the public or open 
 modifier appear in the generated header. 

现在我正在编写一个具有 Objective-C 和 Swift 的混合框架。在其中我定义了一个 swift 类:

import Foundation

@objc(Utility)

internal class Utility:NSObject{

   internal func getMyName() -> String
   {
      return "Got the name!"
   }

}

但我仍然能够在框架的自动生成的 header 中看到这一点:

SWIFT_CLASS_NAMED("Utility")
@interface Utility : NSObject
- (NSString * _Nonnull)getMyName;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

这是在 Xcode 8.2.1 上,不知道为什么它不按照文档声明运行。

最佳答案

我引用了这篇文章 https://stackoverflow.com/a/37324966/1242077 ,并标记了“仅允许应用程序扩展 API”的检查,因为它甚至在自动生成的 header 中列出了内部类和方法。

我使用这个解决方案来保持类私有(private):https://stackoverflow.com/a/33159964/1242077

关于ios - 内部类存在于混合框架的自动生成的 header 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41889119/

相关文章:

android - 我们如何在设备上为基于 phonegap 的 iOS 和 android 应用程序维护错误日志文件 (.txt)?

iphone - 在 objective-c 中测试

ios - skmaps 通过更新 SKAnnotation 来解决巨大的内存泄漏

ios - Firebase Storage iOS 放置在上传完成之前调用的文件完成处理程序

ios - 关于iphone分发私钥问题

ios - UIModalPresentationCurrentContext 和 willRotateToInterfaceOrientation

iphone - 如何在 UITableViewCell 自动换行中制作文本?

objective-c - RestKit POST 非对称 key 错误

ios - 在谷歌登录后使用 Swift 4 推送 View Controller

swift - 无法在 Swift 中从 Facebook 获取电子邮件