require 'pathname'

platform :ios, '9.0'

podfile_dir = Pathname.new(__FILE__).dirname.realpath
root_dir = podfile_dir.ascend.find {|p| p.join('package.json').exist? }

target 'TestApp' do
  pod 'React', :path => root_dir + 'node_modules/react-native/'
  pod 'React-Core', :path => root_dir + 'node_modules/react-native/React'
  pod 'React-DevSupport', :path => root_dir + 'node_modules/react-native/React'
  pod 'React-fishhook', :path => root_dir + 'node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => root_dir + 'node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => root_dir + 'node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => root_dir + 'node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => root_dir + 'node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => root_dir + 'node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => root_dir + 'node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => root_dir + 'node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => root_dir + 'node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => root_dir + 'node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => root_dir + 'node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => root_dir + 'node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => root_dir + 'node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => root_dir + 'node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => root_dir + 'node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => root_dir + 'node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => root_dir + 'node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => root_dir + 'node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => root_dir + 'node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'react-native-awesome-image', :path => root_dir

  target 'TestAppTests' do
    inherit! :search_paths
    
    pod 'OCMock', '~> 3.4'
  end

end

post_install do |installer|
  # Disable some shitty RN stuff (I can't see degradation in functional)
  installer.pods_project.targets.each do |target|
    if target.name == 'React'
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_ENABLE_INSPECTOR=0'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ENABLE_PACKAGER_CONNECTION=0'
      end
    end
  end
end
