braintree / braintree_ios

Braintree SDK for iOS
https://developer.paypal.com/braintree/docs/start/hello-client/ios/v5
MIT License
560 stars 294 forks source link

Braintree/Braintree-Swift.h file not found using CocoaPods #651

Closed ivansnek closed 3 years ago

ivansnek commented 3 years ago

Integration Details:

Describe the bug

I have tested with different import headers:

#import <Braintree/BraintreeCore.h>
---
#import <Braintree/Braintree.h>
#import <Braintree/BraintreeCard.h>
---
#import "BraintreeCore.h"
#import "BTCardNonce.h"

To Reproduce Steps to reproduce the behavior:

  1. There's no explicit steps to reproduce, other than try to update the version

Expected behavior Success build with the latest SDK

Screenshots

Screen Shot 2021-03-22 at 2 34 54 p m
scannillo commented 3 years ago

Hi @ivansnek - we don't offer official support for React Native, as you know. I just made a sample Swift app that included Braintree via CocoaPods (pod 'Braintree', '~> 5.2.0) and don't see this issue.

Does your application use Swift? If so - what version?

ivansnek commented 3 years ago

@scannillo Yes, we implemented the library on the native side, and just created a bridge to access Braintree methods from JS. We use Objective-C as the default language on iOS (This is the default on React Native) but we do support swift code inside the app, using a Objective-C bridging header. It seems we support Swift 5

Is there an Objective-C sample app where I can see how the library is implemented with CocoaPods?

Also one thing to notice here, we're not currently supporting PayPal, is there a way to not include PayPal Pod/library within the Braintree implementation? As you can see in the error, the exception is thrown on a PayPal related file

scannillo commented 3 years ago

Hi @ivansnek.

It seems we support Swift 5

Our SDK requires Swift 5.1, since Swift 5.1 includes module stability. Can't hurt to double check this on your end.

Is there an Objective-C sample app where I can see how the library is implemented with CocoaPods?

No, we don't have a demo to show this. Our repo has a demo app written in ObjC & Swift, but it doesn't pull in Braintree via CocoaPods. It could be helpful if you're looking for some example code, though.

Also one thing to notice here, we're not currently supporting PayPal, is there a way to not include PayPal Pod/library within the Braintree implementation?

Yes! You can only include the modules you need with the following syntax in your Podfile:

pod 'Braintree/Core'
pod 'Braintree/Card'
pod 'Braintree/ApplePay'
... etc

If you do pod 'Braintree', this will include the Core, Card, & PayPal subspecs automatically.

Let us know if this resolves your issue.

ivansnek commented 3 years ago

@scannillo Thank you! the last part resolved my issue, using isolated modules, in my case

pod 'Braintree/Core'
pod 'Braintree/Card'

I didn't found why on building time that header file didn't exists.

jbatra-umeey commented 3 years ago

@ivansnek I am curious to understand how did u resolve the issue. I am still getting the same error in my react-native App

Xcode : 12.4 Swift version : 5.3.2 Braintree : (5.3.0)

Podfile :

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'paypalExample' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'paypalExampleTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'paypalExample-tvOS' do
  # Pods for paypalExample-tvOS

  target 'paypalExample-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

pod 'Braintree/Core'
pod 'Braintree/PayPal'

My podspec

Pod::Spec.new do |s|
  s.name         = "PaypalDemo"
  s.version          = package['version']
  s.summary          = package['name']
  s.license          = package['license']
  s.description  = package['description']
  s.homepage     = "URL"
  s.author             = "Umeey"
  s.platform     = :ios, "12.0"
  s.source       = { URL }
  s.source_files  = "ios/**/*.{h,m}"
  s.dependency "React"
  s.dependency "Braintree/Core"
  s.dependency "Braintree/PayPal"
end

Request you to please share the react-native sample or guide with steps

ivansnek commented 3 years ago

@jbatra-umeey can you try placing the pods inside the target 'paypalExample' I think that might be your issue

jbatra-umeey commented 3 years ago

@ivansnek yes sure. Can you please share your podfile if possible ?

jbatra-umeey commented 3 years ago

@ivansnek I tried the same but no luck. I see that you are not using Paypal. Could you please try to include Paypal and verify the behavior at your end?

ivansnek commented 3 years ago

@jbatra-umeey Actually we use only the individual packages due to an error with PayPal, as you can see in the first image.