gpt4 book ai didi

objective-c - "frameworkname"中的通用类 -Swift.h 在 Xcode 6.3 中导致 "Type name requires a specifier or qualifier"错误

转载 作者:搜寻专家 更新时间:2023-10-30 23:00:09 25 4
gpt4 key购买 nike

我更新到 Xcode 6.3,我的工作区中有两个独立的项目(一个是框架)。现在,Xcode 自动生成了这个“frameworkname”-Swift.h 头文件,但是当我有一个通用类作为属性时,它会生成以下行:

@class Presentation;
SWIFT_CLASS("_TtC13BusinessLogic31MeetupDetailViewControllerModel")
@interface MeetupDetailViewControllerModel : NSObject
@property (nonatomic) /* RsvpStore<Rsvp> */ anRsvpStore;
@end

在 Objective-c 中没有等同于 gerenics,那么我该如何解决这个问题呢?

我发现如果我将类型设置为 NSObject 就可以解决问题:

@property (nonatomic) NSObject * __nonnull anRsvpStore;

但每次构建时,都会将此文件重新创建为相同的错误版本。那么我如何才能强制此构建将此泛型的类型设置为 NSObject?

最佳答案

我可以通过在 Build Settings 中设置来停止创建此兼容性 header -> Swift Compiler - Code Generation -> Intall Objective-C Compatibility Header

因为我没有在我的项目中编写 Objective-C 代码,所以这个选项没有问题,但这更像是一种解决方法,而不是兼容性 header 中泛型的解决方案。

另一种解决方法 是,如果您使用 private 标记您的属性,那么它们将不会出现在兼容性 header 中。

Swift 2.0 更新

A new @nonobjc attribute is introduced to selectively suppress ObjC export for instance members that would otherwise be @objc . (16763754) Blockquote

未经测试,但这看起来像是一个解决方案。

关于objective-c - "frameworkname"中的通用类 -Swift.h 在 Xcode 6.3 中导致 "Type name requires a specifier or qualifier"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29533420/

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