Skip to content

Instantly share code, notes, and snippets.

@BoD
Created November 9, 2021 15:37
Show Gist options
  • Save BoD/16b09a791f9f7d5fc4bcc2d3219937f6 to your computer and use it in GitHub Desktop.
Save BoD/16b09a791f9f7d5fc4bcc2d3219937f6 to your computer and use it in GitHub Desktop.
Generated Header file for ObjC/Swift from a simple example Kotlin Multiplatform library
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSError.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
@class MMLBrandSealedClass, MMLApple, MMLCoffee, MMLKotlinEnumCompanion, MMLKotlinEnum<E>, MMLColorEnum, MMLKotlinArray<T>, MMLOtherDrink, MMLSamsung, MMLSoda, MMLSomeObject, MMLSony, MMLTea;
@protocol MMLDrinkSealedInterface, MMLKotlinComparable, MMLKotlinIterator;
NS_ASSUME_NONNULL_BEGIN
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wincompatible-property-type"
#pragma clang diagnostic ignored "-Wnullability"
#pragma push_macro("_Nullable_result")
#if !__has_feature(nullability_nullable_result)
#undef _Nullable_result
#define _Nullable_result _Nullable
#endif
__attribute__((swift_name("KotlinBase")))
@interface MMLBase : NSObject
- (instancetype)init __attribute__((unavailable));
+ (instancetype)new __attribute__((unavailable));
+ (void)initialize __attribute__((objc_requires_super));
@end;
@interface MMLBase (MMLBaseCopying) <NSCopying>
@end;
__attribute__((swift_name("KotlinMutableSet")))
@interface MMLMutableSet<ObjectType> : NSMutableSet<ObjectType>
@end;
__attribute__((swift_name("KotlinMutableDictionary")))
@interface MMLMutableDictionary<KeyType, ObjectType> : NSMutableDictionary<KeyType, ObjectType>
@end;
@interface NSError (NSErrorMMLKotlinException)
@property (readonly) id _Nullable kotlinException;
@end;
__attribute__((swift_name("KotlinNumber")))
@interface MMLNumber : NSNumber
- (instancetype)initWithChar:(char)value __attribute__((unavailable));
- (instancetype)initWithUnsignedChar:(unsigned char)value __attribute__((unavailable));
- (instancetype)initWithShort:(short)value __attribute__((unavailable));
- (instancetype)initWithUnsignedShort:(unsigned short)value __attribute__((unavailable));
- (instancetype)initWithInt:(int)value __attribute__((unavailable));
- (instancetype)initWithUnsignedInt:(unsigned int)value __attribute__((unavailable));
- (instancetype)initWithLong:(long)value __attribute__((unavailable));
- (instancetype)initWithUnsignedLong:(unsigned long)value __attribute__((unavailable));
- (instancetype)initWithLongLong:(long long)value __attribute__((unavailable));
- (instancetype)initWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable));
- (instancetype)initWithFloat:(float)value __attribute__((unavailable));
- (instancetype)initWithDouble:(double)value __attribute__((unavailable));
- (instancetype)initWithBool:(BOOL)value __attribute__((unavailable));
- (instancetype)initWithInteger:(NSInteger)value __attribute__((unavailable));
- (instancetype)initWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable));
+ (instancetype)numberWithChar:(char)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedChar:(unsigned char)value __attribute__((unavailable));
+ (instancetype)numberWithShort:(short)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedShort:(unsigned short)value __attribute__((unavailable));
+ (instancetype)numberWithInt:(int)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedInt:(unsigned int)value __attribute__((unavailable));
+ (instancetype)numberWithLong:(long)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedLong:(unsigned long)value __attribute__((unavailable));
+ (instancetype)numberWithLongLong:(long long)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable));
+ (instancetype)numberWithFloat:(float)value __attribute__((unavailable));
+ (instancetype)numberWithDouble:(double)value __attribute__((unavailable));
+ (instancetype)numberWithBool:(BOOL)value __attribute__((unavailable));
+ (instancetype)numberWithInteger:(NSInteger)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable));
@end;
__attribute__((swift_name("KotlinByte")))
@interface MMLByte : MMLNumber
- (instancetype)initWithChar:(char)value;
+ (instancetype)numberWithChar:(char)value;
@end;
__attribute__((swift_name("KotlinUByte")))
@interface MMLUByte : MMLNumber
- (instancetype)initWithUnsignedChar:(unsigned char)value;
+ (instancetype)numberWithUnsignedChar:(unsigned char)value;
@end;
__attribute__((swift_name("KotlinShort")))
@interface MMLShort : MMLNumber
- (instancetype)initWithShort:(short)value;
+ (instancetype)numberWithShort:(short)value;
@end;
__attribute__((swift_name("KotlinUShort")))
@interface MMLUShort : MMLNumber
- (instancetype)initWithUnsignedShort:(unsigned short)value;
+ (instancetype)numberWithUnsignedShort:(unsigned short)value;
@end;
__attribute__((swift_name("KotlinInt")))
@interface MMLInt : MMLNumber
- (instancetype)initWithInt:(int)value;
+ (instancetype)numberWithInt:(int)value;
@end;
__attribute__((swift_name("KotlinUInt")))
@interface MMLUInt : MMLNumber
- (instancetype)initWithUnsignedInt:(unsigned int)value;
+ (instancetype)numberWithUnsignedInt:(unsigned int)value;
@end;
__attribute__((swift_name("KotlinLong")))
@interface MMLLong : MMLNumber
- (instancetype)initWithLongLong:(long long)value;
+ (instancetype)numberWithLongLong:(long long)value;
@end;
__attribute__((swift_name("KotlinULong")))
@interface MMLULong : MMLNumber
- (instancetype)initWithUnsignedLongLong:(unsigned long long)value;
+ (instancetype)numberWithUnsignedLongLong:(unsigned long long)value;
@end;
__attribute__((swift_name("KotlinFloat")))
@interface MMLFloat : MMLNumber
- (instancetype)initWithFloat:(float)value;
+ (instancetype)numberWithFloat:(float)value;
@end;
__attribute__((swift_name("KotlinDouble")))
@interface MMLDouble : MMLNumber
- (instancetype)initWithDouble:(double)value;
+ (instancetype)numberWithDouble:(double)value;
@end;
__attribute__((swift_name("KotlinBoolean")))
@interface MMLBoolean : MMLNumber
- (instancetype)initWithBool:(BOOL)value;
+ (instancetype)numberWithBool:(BOOL)value;
@end;
__attribute__((swift_name("BrandSealedClass")))
@interface MMLBrandSealedClass : MMLBase
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Apple")))
@interface MMLApple : MMLBrandSealedClass
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
+ (instancetype)apple __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLApple *shared __attribute__((swift_name("shared")));
@end;
__attribute__((swift_name("DrinkSealedInterface")))
@protocol MMLDrinkSealedInterface
@required
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Coffee")))
@interface MMLCoffee : MMLBase <MMLDrinkSealedInterface>
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)coffee __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLCoffee *shared __attribute__((swift_name("shared")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((swift_name("KotlinComparable")))
@protocol MMLKotlinComparable
@required
- (int32_t)compareToOther:(id _Nullable)other __attribute__((swift_name("compareTo(other:)")));
@end;
__attribute__((swift_name("KotlinEnum")))
@interface MMLKotlinEnum<E> : MMLBase <MMLKotlinComparable>
- (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer));
@property (class, readonly, getter=companion) MMLKotlinEnumCompanion *companion __attribute__((swift_name("companion")));
- (int32_t)compareToOther:(E)other __attribute__((swift_name("compareTo(other:)")));
- (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)")));
- (NSUInteger)hash __attribute__((swift_name("hash()")));
- (NSString *)description __attribute__((swift_name("description()")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@property (readonly) int32_t ordinal __attribute__((swift_name("ordinal")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("ColorEnum")))
@interface MMLColorEnum : MMLKotlinEnum<MMLColorEnum *>
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
@property (class, readonly) MMLColorEnum *red __attribute__((swift_name("red")));
@property (class, readonly) MMLColorEnum *green __attribute__((swift_name("green")));
@property (class, readonly) MMLColorEnum *blue __attribute__((swift_name("blue")));
+ (MMLKotlinArray<MMLColorEnum *> *)values __attribute__((swift_name("values()")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Greeting")))
@interface MMLGreeting : MMLBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (NSString *)greeting __attribute__((swift_name("greeting()")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("OtherBrand")))
@interface MMLOtherBrand : MMLBrandSealedClass
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("OtherDrink")))
@interface MMLOtherDrink : MMLBase <MMLDrinkSealedInterface>
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer));
- (NSString *)component1 __attribute__((swift_name("component1()")));
- (MMLOtherDrink *)doCopyName:(NSString *)name __attribute__((swift_name("doCopy(name:)")));
- (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)")));
- (NSUInteger)hash __attribute__((swift_name("hash()")));
- (NSString *)description __attribute__((swift_name("description()")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Platform")))
@interface MMLPlatform : MMLBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@property (readonly) NSString *platform __attribute__((swift_name("platform")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Samsung")))
@interface MMLSamsung : MMLBrandSealedClass
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
+ (instancetype)samsung __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLSamsung *shared __attribute__((swift_name("shared")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Soda")))
@interface MMLSoda : MMLBase <MMLDrinkSealedInterface>
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)soda __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLSoda *shared __attribute__((swift_name("shared")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("SomeObject")))
@interface MMLSomeObject : MMLBase
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)someObject __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLSomeObject *shared __attribute__((swift_name("shared")));
@property (readonly) MMLBrandSealedClass *brand __attribute__((swift_name("brand")));
@property (readonly) MMLColorEnum *color __attribute__((swift_name("color")));
@property (readonly) MMLCoffee *drink __attribute__((swift_name("drink")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Sony")))
@interface MMLSony : MMLBrandSealedClass
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (instancetype)initWithName:(NSString *)name __attribute__((swift_name("init(name:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
+ (instancetype)sony __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLSony *shared __attribute__((swift_name("shared")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Tea")))
@interface MMLTea : MMLBase <MMLDrinkSealedInterface>
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)tea __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLTea *shared __attribute__((swift_name("shared")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("KotlinEnumCompanion")))
@interface MMLKotlinEnumCompanion : MMLBase
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)companion __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) MMLKotlinEnumCompanion *shared __attribute__((swift_name("shared")));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("KotlinArray")))
@interface MMLKotlinArray<T> : MMLBase
+ (instancetype)arrayWithSize:(int32_t)size init:(T _Nullable (^)(MMLInt *))init __attribute__((swift_name("init(size:init:)")));
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (T _Nullable)getIndex:(int32_t)index __attribute__((swift_name("get(index:)")));
- (id<MMLKotlinIterator>)iterator __attribute__((swift_name("iterator()")));
- (void)setIndex:(int32_t)index value:(T _Nullable)value __attribute__((swift_name("set(index:value:)")));
@property (readonly) int32_t size __attribute__((swift_name("size")));
@end;
__attribute__((swift_name("KotlinIterator")))
@protocol MMLKotlinIterator
@required
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (id _Nullable)next __attribute__((swift_name("next()")));
@end;
#pragma pop_macro("_Nullable_result")
#pragma clang diagnostic pop
NS_ASSUME_NONNULL_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment