Generic classes in "frameworkname" -Swift.h cause "Type name requires qualifier or qualifier" error in Xcode 6.3

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

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

Objective-c has no equal gerenics, so how can I solve this problem?

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

 @property (nonatomic) NSObject * __nonnull anRsvpStore; 

but with each assembly this file is recreated with the same wrong version. So, how can I get this assembly to set this generic type to NSObject?

+5
source share
2 answers

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

Since I did not write Objective-C code in my project, this is not a problem with this option, but it is more of a workaround than a solution for generics in the compatibility header.

Another workaround is if you mark your properties with private then they will not appear in the compatibility header.

Swift 2.0 Update

A new @nonobjc attribute is introduced to selectively suppress ObjC exports, such as members that are otherwise @objc, (16763754) Blockquote

Not tested, but it seems like a solution.

+5
source

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

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

If you need to use swift in objc, you need to edit -Swift.h and set it to Objective-C The name of the generated interface header

+2
source

All Articles