Xcode 7 Generated Interface from Obj-C - Useless?

Just starting out learning Swift and was trying to to use the "Generated Interface" counterpart view of some of my existing Obj-C headers to see how things translate into Swift and to update my own headers with nullability support. But it seems as of Xcode 7 beta 5 that what gets displayed does not match what the swift compiler really uses.


E.g Given this simple Obj-C header:

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, WonderChoice)
{
    WonderChoiceHamburger,
    WonderChoiceHotDog
};
@interface WonderObject : NSObject
@property (nonatomic, copy, nullable) NSString* someString;
@property (nonatomic, copy, nonnull) NSArray* someArray;
@end


results in the following being displayed in Generated Interface:

public func NS_ENUM(NSInteger: Int32, _ WonderChoice: Int32) -> Int32

public class WonderObject {
    public var someString: UnsafeMutablePointer<Int32>
    public var someArray: UnsafeMutablePointer<Int32>
}


which as you can see is mostly useless


When using this code from Swift I can tell that the compiler does have a better view of my header and the code compiles sensibly:

import Foundation
func wonderFunc() -> Void
{
    let choice = WonderChoice.Hamburger;
   
    let wonder = WonderObject()
    wonder.someString = "Hello"
    wonder.someArray = []
}


and it knows not to allow any of the following:

wonder.someArray = nil
wonder.someString = [];


What I was hoping for was for Generated Interfaces of my own headers to be as complete as those provided for system headers.


Is there any way to get the 'real' version of the generated Swift header as used by the compiler itself?

Answered by Wellington in 45088022

It seems that this has been fixed in Xcode 7 beta 6. My generated interface now looks like:


import Foundation
public enum WonderChoice : Int {
   
    case Hamburger
    case HotDog
}
public class WonderObject : NSObject {
    public var someString: String?
    public var someArray: [AnyObject]
}
Accepted Answer

It seems that this has been fixed in Xcode 7 beta 6. My generated interface now looks like:


import Foundation
public enum WonderChoice : Int {
   
    case Hamburger
    case HotDog
}
public class WonderObject : NSObject {
    public var someString: String?
    public var someArray: [AnyObject]
}
Xcode 7 Generated Interface from Obj-C - Useless?
 
 
Q