Include Prefix.pch in bridge header?

Having a project that uses a file Prefix.pch

to import some commonly used frameworks, for example:

// Prefix.pch
@import UIKit;

      

When the objective-c header that uses the included prefix frames is added to the compilation of the bridge header, not detecting classes imported with Prefix.pch

:

// Bridging-Header.h
// UIKit will not be found and will cause errors
#import "FileThatUsesUIKit.h"

      

So far, the cleanest solution found should also contain the file Prefix.pch

up to the rest of the include

s, so that the definitions in the prefix are available as expected:

// Bridging-Header.h
#import "Prefix.pch"
#import "FileThatUsesUIKit.h"

      

Alternatively, a specific structure can be imported directly into the file Bridging-Header.h

, but this is because it maintains definition negotiation between the prefix file and the bridge header:

// Bridging-Header.h
@import UIKit;
#import "FileThatUsesUIKit.h"

      

Is importing file Prefix.pch

to file Bridging-Header.h

correct approach? Are there other alternatives?

+3


source to share





All Articles