source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/ololabs/podspecs.git'

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

# Uncomment the next line to define a global platform for your project
platform :ios, '14.0'

target 'OlopaysdkReactNative' do
  use_react_native!
  use_native_modules!

  # Pods for OlopaysdkReactNative
  pod 'OloPaySDK', :git => 'https://github.com/ololabs/olo-pay-ios-sdk-releases.git', :tag => '4.1.0'
end

# Workaround to support dynamic frameworks with React Native
dynamic_frameworks = ['OloPaySDK', 'Stripe', 'StripeCore', 'StripeUICore', 'StripeApplePay', 'StripePayments', 'StripePaymentsUI']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if dynamic_frameworks.include?(pod.name)
      puts "Overriding the build_type to dynamic_framework for #{pod.name}"
      def pod.build_type;
        Pod::BuildType.dynamic_framework
      end
    end
  end
end

# Needed due to changes in Xcode 14...
# Solution found here: https://stackoverflow.com/questions/72561696/xcode-14-needs-selected-development-team-for-pod-bundles
# Disable signing for pods
post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
         end
    end
  end
end
