# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
# # Resolve react_native_pods.rb with node to allow for hoisting
# def node_require(script)
# # Resolve react_native_pods.rb with node to allow for hoisting
# require Pod::Executable.execute_command('node', ['-p',
#   'require.resolve(
#     "react-native/scripts/react_native_pods.rb",
#     {paths: [process.argv[1]]},
#   )', __dir__]).strip

# end
# node_require('react-native/scripts/react_native_pods.rb')
# node_require('react-native-permissions/scripts/setup.rb')

# platform :ios,'15.1'
# prepare_react_native_project!

# flags = {
#   fabric_enabled: true, # ✅ Required for Reanimated layout animations
#   hermes_enabled: true  # or false based on your setup
# }


# linkage = ENV['USE_FRAMEWORKS']
# # if linkage != nil
# #   Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
# #   use_frameworks! :linkage => linkage.to_sym
# # end

# use_frameworks! :linkage => :static
# $RNFirebaseAsStaticFramework = true

# target 'GocabDriver' do
#   config = use_native_modules!
#   flags = get_default_flags()


#   use_react_native!(
#     :path => config[:reactNativePath],
#     # An absolute path to your application root.
#     :hermes_enabled => flags[:hermes_enabled],
#     :fabric_enabled => flags[:fabric_enabled],
#     :app_path => "#{Pod::Config.instance.installation_root}/.."
#   )


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

#   pre_install do |installer|
#     installer.pod_targets.each do |pod|
#       if pod.name.eql?('react-native-chat-head')
#         Pod::UI.puts "⚠️  Skipping pod: #{pod.name} (Android-only)"
#         pod.target_definitions.each do |definition|
#           definition.dependencies.delete_if { |dep| dep.name.eql?('react-native-chat-head') }
#         end
#       end
#     end
#   end

#   post_install do |installer|
#     # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
#     react_native_post_install(
#       installer,
#       config[:reactNativePath],
#       :mac_catalyst_enabled => false,
#       # :ccache_enabled => true
#     )
#   end
# end



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

def node_require(script)
 require Pod::Executable.execute_command('node', ['-p',
 "require.resolve(
 '#{script}',
 {paths: [process.argv[1]]},
 )", __dir__]).strip
end

node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

platform :ios, '15.1'
prepare_react_native_project!

setup_permissions([
 'Camera',
 'LocationAlways',
 'LocationWhenInUse',
 'PhotoLibrary',
 'PhotoLibraryAdd',
])

flags = {
 fabric_enabled: true, # Needed for Reanimated layout animations
 hermes_enabled: true # or false if not using Hermes
}

use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true

target 'GocabDriver' do
 config = use_native_modules!
 flags = get_default_flags()

 use_react_native!(
 :path => config[:reactNativePath],
 :hermes_enabled => flags[:hermes_enabled],
 :fabric_enabled => flags[:fabric_enabled],
 :app_path => "#{Pod::Config.instance.installation_root}/.."
 )

 # Remove all permissions for now to avoid issues

 pre_install do |installer|
 installer.pod_targets.each do |pod|
 if pod.name.eql?('react-native-chat-head')
 Pod::UI.puts "⚠️ Skipping pod:#{pod.name} (Android-only)"
 pod.target_definitions.each do |definition|
 definition.dependencies.delete_if { |dep| dep.name.eql?('react-native-chat-head') }
 end
 end
 end
 end

 post_install do |installer|
 react_native_post_install(
 installer,
 config[:reactNativePath],
 :mac_catalyst_enabled => false
 )

 # Allow Swift imports like `import React`
 installer.pods_project.targets.each do |target|
 if ['React-Core', 'React-CoreModules', 'React-RCTAppDelegate', 'ReactCommon'].include?(target.name)
 target.build_configurations.each do |config|
 config.build_settings['DEFINES_MODULE'] = 'YES'
 end
 end
 end
 end
end