I have following code in Swift:
@objc
class Type1 {
@objc var Details: Details
@objc(Type1Details)
class Details {}
}
@objc
class Type2: Type1 {
@objc var Details: Details
@objc(Type2Details)
class Details: Type1.Details {}
}
The generated Swift Generated header gives following warning in such case:
Module-Swift.h: Property type 'Type2Details * _Nonnull' is incompatible with type 'Type1Details * _Nonnull' inherited from 'Type1'
This warning doesn’t make sense as Type2Details inherits Type1Details. From what I have found out from developers facing such errors the header file needs to be modified to prevent this error:
- By ordering the
Type2Detailsdefinition above its usage - Or by ignoring this diagnostic.
For point 1, I couldn’t find any way to achieve ordering definitions in the generated header. So I went with option 2 with custom script phase that modifies the generated header to ignore the diagnostics.
In my opinion this diagnostic doesn’t make sense in Swift generated header since Swift compiler does the type checking, allowing issues with type safety being caught during compile time.