# React Native requirements
puts "Remove node_modules"
output = `rm -rf ../node_modules/`
puts output
output = `rm -rf node_modules/`
puts output

puts "Remove yarn.lock"
output = `rm -rf ../yarn.lock`
puts output
output = `rm -rf yarn.lock`
puts output

puts "Install yarn tool"
output = `brew install yarn`
puts output

puts "Install react native directory and sources"
output = `cd .. && yarn install`
puts output

install! 'cocoapods', :disable_input_output_paths => true
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.4'

target 'RNAcousticMobilePush' do
  use_frameworks! :linkage => :static
  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
  )

  # 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)
  # end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    puts "Target: #{target.name}"
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
    end
  end
  installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end