Search code examples
objective-cswiftbraintreebridging-header

Why is my simple objective c bridging header failing to find the file "BraintreeCore.h"?


This is really frustrating me. I've integrated the Braintree library into several iOS projects before to be used in swift and never really had a problem but currently I can't get it to work.

I have followed/repeated the instructions here over and over:

https://developers.braintreepayments.com/start/hello-client/ios/v4

Specifically, i put pod 'Braintree' in my Podfile, ran a pod install and pod update, and have verified the Braintree library now appears in the Pods directory.

I have re made my bridging header 3 times now too, being careful to set the target to my app. I've also verified over and over that I have set the objective c bridging header in my Build Settings to the correct file, and have it succesfully creating bridging headers for other objective c files. Sadly though the following lines just aren't working in the bridging header:

#import "BraintreeCore.h"
#import "BraintreeUI.h"

They both give a compile error of the same type, saying BraintreeCore.h file not found.

I was able to do the following without getting an error:

#import "Pods/Braintree/BraintreeCore/Public/BraintreeCore.h"

But when I try and do the same for BraintreeUI.h like so:

#import "Pods/Braintree/BraintreeUI/Public/BraintreeUI.h"

It links me to the BraintreeUI.h file and tells me "BraintreeCore/BraintreeCore.h" file not found about this line in the BraintreeUI.h file:

#import <BraintreeCore/BraintreeCore.h>

What am I doing wrong?? this should be straightforward but it's been infuriating me for over 12 hours now.


Solution

  • Full disclosure: I work at Braintree on the iOS SDK.

    Your bridging header should not need you to specify a path to the umbrella header files. This might indicate that your Xcode project's build configuration is set up so that Xcode's build system can't find the header files. In a typical project, you should be able to do this no problem.

    My suggestion would be to take a close look at the Project > Build Settings > Search Paths settings. In particular, the Header Search Paths setting should contain one entry that looks like this:

    "${PODS_ROOT}/Headers/Public/Braintree"

    If it doesn't, I suspect that CocoaPods is not playing nice with your Xcode project. You may want to try de-integrating and re-integrating. Using CocoaPods 1.0, you should be able to do pod deintegrate, make sure your Pods/ folder is deleted, and run pod install. Worst case possibility, you may just want to start with a brand-new Xcode project and drag over your old source files (although that might be a big pain).