Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error importing TrustKit.h into .mm file #160

Closed
cohenadair opened this issue Mar 7, 2018 · 3 comments
Closed

Build error importing TrustKit.h into .mm file #160

cohenadair opened this issue Mar 7, 2018 · 3 comments
Milestone

Comments

@cohenadair
Copy link

cohenadair commented Mar 7, 2018

Importing TrustKit into an Objective-C++ (.mm) file via #import <TrustKit/TrustKit.h> results in the following build error:

Use of '@import' when C++ modules are disabled, consider using fmodules and fcxx-modules

From what I've read, C++ modules are disabled for Objective-C++ files, and the @import directive isn't allowed.

This seems to be a common problem in Pod libraries, other's have fixed it by doing something like:

#if __has_feature(modules)
    @import Foundation;
#else
    #import <Foundation/Foundation.h>
#endif

For others having this issue

A workaround is to create a TrustKitWrapper.h/m class and create wrapper methods for TrustKit APIs you need, then import TrustKitWrapper.h into your .mm files. Something like:

@interface TrustKitWrapper : NSObject

+ (void)setupTrustKitInstance;
+ (bool)handleChallenge:(NSURLAuthenticationChallenge *)challenge;

@end
@boehlefeld
Copy link

Thanks @cohenadair , I do have the same issue here tryin to import TrustKit in Cedar BDD Testing. How about making a PR?

@cohenadair
Copy link
Author

cohenadair commented Mar 16, 2018

@boehlefeld I'm not likely to have the time anytime soon, but I'll add it to my list of things to do.

@nabla-c0d3 nabla-c0d3 modified the milestones: 1.60, 1.6.0 Jun 5, 2018
@nabla-c0d3
Copy link
Member

Released with v1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants