wgltony / react-native-braintree-dropin-ui

React Native integration of Braintree Drop-in for IOS & ANDROID (Apple Pay, Google Pay, Paypal, Venmo, Credit Card)
MIT License
78 stars 104 forks source link

Xcode 12.5 Support #71

Open dclawson opened 3 years ago

dclawson commented 3 years ago

Is there a working fork or method to be able to build in Xcode 12.5 at all?

Build error: ios/Pods/BraintreeDropIn/BraintreeDropIn/BTDropInController.m:423:67: 'topLayoutGuide' is deprecated: first deprecated in iOS 11.0 - Use view.safeAreaLayoutGuide.topAnchor instead of topLayoutGuide.bottomAnchor

samzmann commented 3 years ago

This is not an xcode issue. Its a bug in the native braintree lib https://github.com/braintree/braintree-ios-drop-in/issues/209. It was fixed, but not in this lib because it's not so up to date.

To prevent this, make sure that the target ios version (IPHONEOS_DEPLOYMENT_TARGET) of the BraintreeDropIn Pod is bellow 11. I believe the default is 9.0, so leave it at that.

1280103995 commented 3 years ago

This is not an xcode issue. Its a bug in the native braintree lib braintree/braintree-ios-drop-in#209. It was fixed, but not in this lib because it's not so up to date.

To prevent this, make sure that the target ios version (IPHONEOS_DEPLOYMENT_TARGET) of the BraintreeDropIn Pod is bellow 11. I believe the default is 9.0, so leave it at that.

Could you guide us how to "make sure that the target ios version (IPHONEOS_DEPLOYMENT_TARGET) of the BraintreeDropIn Pod is bellow 11"?

samzmann commented 3 years ago

@1280103995 Sure. This is what my pod_install statement looks like, at the bottom of ios/Podfile:

post_install do |installer|

  flipper_post_install(installer)

  installer.pods_project.targets.each do |target|
    targets_to_ignore = %w(React yoga)
    if targets_to_ignore.include? target.name
        target.remove_from_project
    end
    target.build_configurations.each do |config|
        if target.name == "BraintreeDropIn"
            #  Do nothing because BraintreeDropIn has a bug and requires lower target OS.
            #  This condition should be removed after a future update that fixes this.
        else
            #  This removes any Pod specific deployment target to ensure the project target is used.
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
    end
  end

end

The relevant part is in the target.build_configurations.each loop:

Note that your Podfile might have some different logic so you might have to do this differently. Hope this helps!

1280103995 commented 3 years ago

@1280103995 Sure. This is what my pod_install statement looks like, at the bottom of ios/Podfile:

post_install do |installer|

  flipper_post_install(installer)

  installer.pods_project.targets.each do |target|
    targets_to_ignore = %w(React yoga)
    if targets_to_ignore.include? target.name
        target.remove_from_project
    end
    target.build_configurations.each do |config|
        if target.name == "BraintreeDropIn"
            #  Do nothing because BraintreeDropIn has a bug and requires lower target OS.
            #  This condition should be removed after a future update that fixes this.
        else
            #  This removes any Pod specific deployment target to ensure the project target is used.
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
    end
  end

end

The relevant part is in the target.build_configurations.each loop:

  • if target.name is "BraintreeDropIn", do nothing (keep the Pod's target setting)
  • else delete the IPHONEOS_DEPLOYMENT_TARGET setting to make sure all Pods use the project target

Note that your Podfile might have some different logic so you might have to do this differently. Hope this helps!

I was unlucky. After many builds, I still encountered the same error (no error was reported once). But thank you for the code.

1280103995 commented 3 years ago

@1280103995 Sure. This is what my pod_install statement looks like, at the bottom of ios/Podfile:

post_install do |installer|

  flipper_post_install(installer)

  installer.pods_project.targets.each do |target|
    targets_to_ignore = %w(React yoga)
    if targets_to_ignore.include? target.name
        target.remove_from_project
    end
    target.build_configurations.each do |config|
        if target.name == "BraintreeDropIn"
            #  Do nothing because BraintreeDropIn has a bug and requires lower target OS.
            #  This condition should be removed after a future update that fixes this.
        else
            #  This removes any Pod specific deployment target to ensure the project target is used.
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
    end
  end

end

The relevant part is in the target.build_configurations.each loop:

  • if target.name is "BraintreeDropIn", do nothing (keep the Pod's target setting)
  • else delete the IPHONEOS_DEPLOYMENT_TARGET setting to make sure all Pods use the project target

Note that your Podfile might have some different logic so you might have to do this differently. Hope this helps!

Hello, @LaVielle ! I tried it again today and it worked. I did this: delete the Pods folder and Podfile.lock file in the ios folder, and execute pod install. Then execute Clean build folder in Xcode and rebuild. :)

CyberTron88 commented 2 years ago

I think I am having the same issue. Below is the bottom of my pod file

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

platform :ios, '11'

target 'XXXXXXXX' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'XXXXXXXXTests' 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 the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

Tried adding

    target.build_configurations.each do |config|
        if target.name == "BraintreeDropIn"
            #  Do nothing because BraintreeDropIn has a bug and requires lower target OS.
            #  This condition should be removed after a future update that fixes this.
        else
            #  This removes any Pod specific deployment target to ensure the project target is used.
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
    end

above the react_native_post_install(installer), pod install will throw some errors

andrew-stupchuk commented 2 years ago

any updates on that? solution on the top doesnt help me(

CyberTron88 commented 2 years ago

I ended up editing the braintree dropin source code to remove the 3 lines Pods/BraintreeDropIn/BraintreeDropIn/BTDropInController.m since I am building for iOS 11 and above.

On Mon, Nov 22, 2021 at 7:23 PM andrew-stupchuk @.***> wrote:

any updates on that? solution on the top doesnt help me(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wgltony/react-native-braintree-dropin-ui/issues/71#issuecomment-975422262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWO5WD25IERRFF22KSSB3FDUNIR4LANCNFSM44YR43LQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

andrew-stupchuk commented 2 years ago

if somebody still has this problem just add next line to your Podfile

pod 'BraintreeDropIn', :inhibit_warnings => true
1280103995 commented 2 years ago

如果有人仍然有这个问题,只需将下一行添加到您的 Podfile

pod 'BraintreeDropIn', :inhibit_warnings => true

Great! I will try it.

I am using this now and it works fine.

installer.pods_project.targets.each do |target|
     target.build_configurations.each do |config|
          if target.name == "BraintreeDropIn"
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
          end
    end
end