1# Copyright (c) Meta Platforms, Inc. and affiliates.
2#
3# This source code is licensed under the MIT license found in the
4# LICENSE file in the root directory of this source tree.
5
6require "json"
7
8package = JSON.parse(File.read(File.join(__dir__, "package.json")))
9version = package['version']
10
11
12
13folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
14folly_version = '2021.07.22.00'
15boost_compiler_flags = '-Wno-documentation'
16
17use_hermes = ENV['USE_HERMES'] == '1'
18
19header_subspecs = {
20  'CoreModulesHeaders'          => 'React/CoreModules/**/*.h',
21  'RCTActionSheetHeaders'       => 'Libraries/ActionSheetIOS/*.h',
22  'RCTAnimationHeaders'         => 'Libraries/NativeAnimation/{Drivers/*,Nodes/*,*}.{h}',
23  'RCTBlobHeaders'              => 'Libraries/Blob/{ABI48_0_0RCTBlobManager,ABI48_0_0RCTFileReaderModule}.h',
24  'RCTImageHeaders'             => 'Libraries/Image/*.h',
25  'RCTLinkingHeaders'           => 'Libraries/LinkingIOS/*.h',
26  'RCTNetworkHeaders'           => 'Libraries/Network/*.h',
27  'RCTPushNotificationHeaders'  => 'Libraries/PushNotificationIOS/*.h',
28  'RCTSettingsHeaders'          => 'Libraries/Settings/*.h',
29  'RCTTextHeaders'              => 'Libraries/Text/**/*.h',
30  'RCTVibrationHeaders'         => 'Libraries/Vibration/*.h',
31}
32
33header_search_paths = [
34  "$(PODS_TARGET_SRCROOT)/ReactCommon",
35  "$(PODS_ROOT)/boost",
36  "$(PODS_ROOT)/DoubleConversion",
37  "$(PODS_ROOT)/RCT-Folly",
38  "${PODS_ROOT}/Headers/Public/FlipperKit",
39  "$(PODS_ROOT)/Headers/Public/ReactCommon",
40  "$(PODS_ROOT)/Headers/Public/React-RCTFabric"
41].concat(use_hermes ? [
42  "$(PODS_ROOT)/Headers/Public/ABI48_0_0React-hermes",
43  "$(PODS_ROOT)/Headers/Public/ABI48_0_0hermes-engine"
44] : []).map{|p| "\"#{p}\""}.join(" ")
45
46Pod::Spec.new do |s|
47  s.name                   = "ABI48_0_0React-Core"
48  s.version                = version
49  s.summary                = "The core of React Native."
50  s.homepage               = "https://reactnative.dev/"
51  s.license                = package["license"]
52  s.author                 = "Facebook, Inc. and its affiliates"
53  s.platforms              = { :ios => "12.4" }
54  s.source                 = { :path => "." }
55  s.resource_bundle        = { "ABI48_0_0AccessibilityResources" => ["React/AccessibilityResources/*.lproj"]}
56  s.compiler_flags         = folly_compiler_flags + ' ' + boost_compiler_flags
57  s.header_dir             = "ABI48_0_0React"
58  s.framework              = "JavaScriptCore"
59  s.pod_target_xcconfig    = {
60                               "HEADER_SEARCH_PATHS" => header_search_paths,
61                               "DEFINES_MODULE" => "YES",
62                               "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}",
63                               "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
64                             }.merge!(use_hermes ? {
65                               "FRAMEWORK_SEARCH_PATHS" => "\"$(PODS_CONFIGURATION_BUILD_DIR)/ABI48_0_0React-hermes\""
66                             } : {})
67  s.user_target_xcconfig   = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/ABI48_0_0React-Core\""}
68  s.default_subspec        = "Default"
69
70  s.subspec "Default" do |ss|
71    ss.source_files           = "React/**/*.{c,h,m,mm,S,cpp}"
72    exclude_files = [
73      "React/CoreModules/**/*",
74      "React/DevSupport/**/*",
75      "React/Fabric/**/*",
76      "React/FBReactNativeSpec/**/*",
77      "React/Tests/**/*",
78      "React/Inspector/**/*"
79    ]
80    # If we are using Hermes (the default is use hermes, so USE_HERMES can be nil), we don't have jsc installed
81    # So we have to exclude the JSCExecutorFactory
82    #
83    # NOTE(kudo): Exposing JSC files as Expo Go hosts duo engines
84    # if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
85    #   exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
86    # end
87    ss.exclude_files = exclude_files
88    ss.private_header_files   = "React/Cxx*/*.h"
89  end
90
91  s.subspec "DevSupport" do |ss|
92    ss.source_files = "React/DevSupport/*.{h,mm,m}",
93                      "React/Inspector/*.{h,mm,m}"
94
95    ss.dependency "ABI48_0_0React-Core/Default", version
96    ss.dependency "ABI48_0_0React-Core/RCTWebSocket", version
97    ss.dependency "ABI48_0_0React-jsinspector", version
98  end
99
100  s.subspec "RCTWebSocket" do |ss|
101    ss.source_files = "Libraries/WebSocket/*.{h,m}"
102    ss.dependency "ABI48_0_0React-Core/Default", version
103  end
104
105  # Add a subspec containing just the headers for each
106  # pod that should live under <React/*.h>
107  header_subspecs.each do |name, headers|
108    s.subspec name do |ss|
109      ss.source_files = headers
110      ss.dependency "ABI48_0_0React-Core/Default"
111    end
112  end
113
114  s.dependency "RCT-Folly", folly_version
115  s.dependency "ABI48_0_0React-cxxreact", version
116  s.dependency "ABI48_0_0React-perflogger", version
117  s.dependency "ABI48_0_0React-jsi", version
118  s.dependency "ABI48_0_0React-jsiexecutor", version
119  s.dependency "ABI48_0_0Yoga"
120  s.dependency "glog"
121
122  if ENV['USE_HERMES'] == "0"
123    s.dependency 'ABI48_0_0React-jsc'
124  else
125    s.dependency 'ABI48_0_0React-hermes'
126    s.dependency 'ABI48_0_0hermes-engine'
127  end
128end
129