gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:18:39 26 4
gpt4 key购买 nike

根据有关内部访问修饰符的 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/

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