# changes from here: https://docs.expo.dev/bare/installing-expo-modules/
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require_relative '../../../node_modules/react-native/scripts/react_native_pods'
require_relative '../../../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../../../node_modules/react-native-permissions/scripts/setup'

platform :ios, '15.0'
prepare_react_native_project!

setup_permissions([
  'FaceID',
  'Notifications',
])

$RNFirebaseAsStaticFramework = true
$RNFirebaseAnalyticsWithoutAdIdSupport=true

target 'Uniswap' do
  use_frameworks! :linkage => :static
  use_expo_modules!
  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
  use_expo_modules!(exclude: ['expo-constants','expo-file-system', 'expo-font', 'expo-keep-awake', 'expo-error-recovery'])
  config = use_native_modules!

  flipper_config = ENV['USE_FLIPPER'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled

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

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

  pod 'EthersRS', :path =>  '../../../node_modules/@uniswap/ethers-rs-mobile'
  pod 'Argon2Swift', '1.0.3'

  post_install do |installer|
    react_native_post_install(installer, "../../../node_modules/react-native")

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
      end
    end
  end
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks! :linkage => :static
  pod 'OneSignalXCFramework', '3.12.6'
end

def prepare_target_commons
  use_frameworks! :linkage => :static

  pod 'Apollo', '1.2.1'
  pod 'UIImageColors', '2.1.0'
end

target 'Widgets' do
  prepare_target_commons
  # Pods for widgets
end
target 'WidgetsCore' do
  prepare_target_commons
  # Pods for widgets core
end
target 'WidgetsCoreTests' do
  prepare_target_commons
  # Pods for widgets core test
end
target 'WidgetIntentExtension' do
  prepare_target_commons
  # Pods for intent extension
end
