Generic classes in "frameworkname"-Swift.h causes "Type name requires a specifier or qualifier" error in Xcode 6.3
Asked Answered
S

2

5

I updated to Xcode 6.3, and I had two separate projects (one is a framework) in my workspace. Now, Xcode autogenerated this "frameworkname"-Swift.h header file, but when I had a generic class as a property, it produces the following lines:

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

There is no equialent to gerenics in Objective-c, so how can I solve this problem?

I found that I can solve the problem if I set the type to NSObject like:

@property (nonatomic) NSObject * __nonnull anRsvpStore;

but with every build, this file is recreated to the same wrong version. So how can I force this build to set the type of this generic to NSObject?

Separative answered 9/4, 2015 at 8:23 Comment(0)
S
5

I could stop creating this compatibility header by setting in Build Settings -> Swift Compiler - Code Generation -> Intall Objective-C Compatibility Header to No.

Since I've not written Objective-C code in my project, there is no problem with this option, but this is rather a workaround than a solution for generics in the compatibility header.

Another workaround is if you mark your properties with private, then they won't appear in the compatibility header.

Swift 2.0 update

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

Not tested, but this looks like a solution.

Separative answered 9/4, 2015 at 11:35 Comment(0)
F
2

I solved in #1873 https://github.com/realm/realm-cocoa/issues/1873

If you don't need to use swift in objc,just set Intall Objective-C Compatibility Header to No.

If you need to use swift in objc,you have to edited the -Swift.h and set it in Objective-C Generated Interface Header Name

Financial answered 11/6, 2015 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.