1require 'json'
2
3package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
5reactNativeVersion = '0.0.0'
6begin
7  reactNativeVersion = `node --print "require('react-native/package.json').version"`
8rescue
9  reactNativeVersion = '0.0.0'
10end
11if ENV["REACT_NATIVE_OVERRIDE_VERSION"]
12  reactNativeVersion = ENV["REACT_NATIVE_OVERRIDE_VERSION"]
13end
14
15REACT_NATIVE_MINOR_VERSION = reactNativeVersion.split('.')[1].to_i
16
17fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
18fabric_compiler_flags = '-DRN_FABRIC_ENABLED'
19folly_version = '2021.07.22.00'
20folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
21
22Pod::Spec.new do |s|
23  s.name           = 'ExpoModulesCore'
24  s.version        = package['version']
25  s.summary        = package['description']
26  s.description    = package['description']
27  s.license        = package['license']
28  s.author         = package['author']
29  s.homepage       = package['homepage']
30  s.platform       = :ios, '13.0'
31  s.swift_version  = '5.4'
32  s.source         = { git: 'https://github.com/expo/expo.git' }
33  s.static_framework = true
34  s.header_dir     = 'ExpoModulesCore'
35
36  # Swift/Objective-C compatibility
37  s.pod_target_xcconfig = {
38    'USE_HEADERMAP' => 'YES',
39    'DEFINES_MODULE' => 'YES',
40    'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
41    'SWIFT_COMPILATION_MODE' => 'wholemodule',
42    'HEADER_SEARCH_PATHS' => "\"$(PODS_ROOT)/boost\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
43    'OTHER_SWIFT_FLAGS' => "$(inherited) #{fabric_enabled ? fabric_compiler_flags : ''}"
44  }
45  s.user_target_xcconfig = {
46    "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"",
47  }
48
49  compiler_flags = folly_compiler_flags + ' ' + "-DREACT_NATIVE_MINOR_VERSION=#{REACT_NATIVE_MINOR_VERSION}"
50
51  s.dependency 'React-Core'
52  s.dependency 'ReactCommon/turbomodule/core'
53
54  if fabric_enabled
55    compiler_flags << ' ' << fabric_compiler_flags
56
57    s.dependency 'React-RCTFabric'
58    s.dependency 'RCT-Folly', folly_version
59  end
60
61  if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("ios/#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
62    s.source_files = 'ios/**/*.h', 'common/cpp/**/*.h'
63    s.vendored_frameworks = "ios/#{s.name}.xcframework"
64  else
65    s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}'
66  end
67
68  exclude_files = ['ios/Tests/']
69  if !fabric_enabled
70    exclude_files.append('ios/Fabric/')
71    exclude_files.append('common/cpp/fabric/')
72  end
73
74  s.exclude_files = exclude_files
75  s.compiler_flags = compiler_flags
76  s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
77
78  s.test_spec 'Tests' do |test_spec|
79    test_spec.dependency 'ExpoModulesTestCore'
80
81    test_spec.source_files = 'ios/Tests/**/*.{m,swift}'
82  end
83end
84