[SR-6958] ClangImporter ignore aliased Objective-C type name #49506
Swift 4.0.3. Xcode 9.2
Additional Detail from JIRA
When importing Objective-C function signature with basic primitive type aliased with the typedef, the function is imported with the aliased type name, not with the used alias:
typedef NSUInteger PageIndex; - (nullable NSURL *)pathForPageAtIndex:(PageIndex)pageIndex;
func pathForPage(at pageIndex: UInt) -> URL?
func pathForPage(at pageIndex: PageIndex) -> URL?
The text was updated successfully, but these errors were encountered:
It may be something with the NSUInteger. Here is my current workaround where I basically mimic the NSUInteger type:
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 typedef unsigned long PageIndex; #else typedef unsigned int PageIndex; #endif
Will try to build self-contained example.
Certain types are recognized as "word-sized", something that needs information beyond what you get out of a preprocessed C file.
I see. I thought you said "
Typedefs: - Name: "PSPDFPageIndex" SwiftBridge: "Swift.UInt"
and if I look at the generated interface, it's UInt, but it doesn't seem to impact the type checked as it still thinks it's UInt32 eg.
Cannot convert value of type 'PSPDFPageIndex' (aka 'UInt32') to expected argument type 'UInt'
To add, for the type defined like this:
typedef unsigned long PSPDFUInteger; typedef PSPDFUInteger PSPDFPageIndex NS_SWIFT_NAME(PageIndex);
- (nullable NSURL *)pathForPageAtIndex:(PSPDFPageIndex)pageIndex;
it's imported as
func pathForPage(at pageIndex: Any!) -> URL?
so it looks like there is something missing with typedef resolving.