swift 2.0 compile error in generated swift.h file about SecCertificateRef
Asked Answered
E

0

8

in our swift code somewhere there is a class with a method with this signature:

static var getCertificates : [SecCertificate] { ... }

in the generated app-swift.h this results in:

 @interface TrustedCertificates : NSObject
     + (NSArray<SecCertificateRef> * __nonnull)getCertificates;
 @end

and this gives the compile error:

 Type argument 'SecCertificateRef' (aka 'struct __SecCertificate *') is neither an Objective-C object nor a block type

I've tried adding #import before where the .h file is included, but it doesn't solve the error. I've also tried adding the import to the pch.h file but this also doesn't help.

Since the swift file is generated I can not start editing it there since it will be overwritten anyway.

Any idea what is missing to get it to compile?

Ellisellison answered 3/9, 2015 at 16:40 Comment(5)
This looks like a bug. The correct type should probably be just NSArray or CFArrayRef.Oriflamme
I don't think thats the bug. I've read Objective C now also supports typed arrays. So this is probably the syntax for it. The problem lies in the fact that it doesn't know the SecCertifcateRef typeEllisellison
No, the problem lies in the fact that SecCertificateRef is not an Objective-C type. Just like you can't have a NSArray<CFStringRef> (even though you can have a NSArray<NSString>), you can't have a NSArray<SecCertificateRef>. This is why I'm saying that it's a bug: the automatically generated code is incorrect.Oriflamme
That makes sense! If you make it an answer I can upvote you more. I'll see if I can work around it and I'll submit a radarEllisellison
I'll double that on up-voting as an answer… :)Baptism

© 2022 - 2024 — McMap. All rights reserved.