Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 366
Dániel Nagy Avatar asked Apr 09 '15 08:04

Dániel Nagy


2 Answers

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.

like image 138
Dániel Nagy Avatar answered Oct 16 '22 15:10

Dániel Nagy


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

like image 2
github2016a Avatar answered Oct 16 '22 14:10

github2016a