require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
  s.name           = 'ExpoModulesWorklets'
  s.version        = package['version']
  s.summary        = package['description']
  s.description    = package['description']
  s.license        = package['license']
  s.author         = package['author']
  s.homepage       = package['homepage']
  s.platforms       = {
    :ios => '16.4',
    :osx => '13.4',
    :tvos => '16.4'
  }
  s.swift_version  = '6.0'
  s.source         = { git: 'https://github.com/expo/expo.git' }
  s.static_framework = true
  s.header_dir     = 'ExpoModulesWorklets'

  s.pod_target_xcconfig = {
    'USE_HEADERMAP' => 'YES',
    'DEFINES_MODULE' => 'YES',
    'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
  }

  s.dependency 'ExpoModulesJSI'
  s.dependency 'ExpoModulesCore'

  s.source_files = 'ios/Worklets/**/*.{h,m,mm,swift,cpp}'
  s.private_header_files = 'ios/Worklets/**/*+Private.h'

  s.test_spec 'Tests' do |test_spec|
    # ExpoModulesCore requires React-hermes or React-jsc in tests, add ExpoModulesTestCore for the underlying dependencies
    test_spec.dependency 'ExpoModulesTestCore'

    test_spec.source_files = 'ios/WorkletsTests/**/*.{m,swift}'
    # The test bundle links libExpoModulesCore.a (C++). ExpoModulesCore adds -lc++ in its
    # `user_target_xcconfig`, which a test_spec target doesn't inherit, so link libc++ explicitly.
    test_spec.pod_target_xcconfig = {
      'OTHER_LDFLAGS' => '$(inherited) -lc++'
    }
  end
end
