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_flags = ' -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
14folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
15
16is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] == "1"
17new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "")
18is_fabric_enabled = is_new_arch_enabled || ENV["RCT_FABRIC_ENABLED"]
19fabric_flag = (is_fabric_enabled ? " -DRN_FABRIC_ENABLED" : "")
20other_cflags = "$(inherited)" + folly_flags + new_arch_enabled_flag + fabric_flag
21
22use_hermes = ENV['USE_HERMES'] == '1'
23use_frameworks = ENV['USE_FRAMEWORKS'] != nil
24
25header_search_paths = [
26  "$(PODS_TARGET_SRCROOT)/ReactCommon",
27  "$(PODS_ROOT)/Headers/Private/ABI49_0_0React-Core",
28  "$(PODS_ROOT)/boost",
29  "$(PODS_ROOT)/DoubleConversion",
30  "$(PODS_ROOT)/RCT-Folly",
31  "${PODS_ROOT}/Headers/Public/FlipperKit",
32  "$(PODS_ROOT)/Headers/Public/ABI49_0_0ReactCommon",
33  "$(PODS_ROOT)/Headers/Public/ABI49_0_0React-RCTFabric"
34].concat(use_hermes ? [
35  "$(PODS_ROOT)/Headers/Public/ABI49_0_0React-hermes",
36  "$(PODS_ROOT)/Headers/Public/ABI49_0_0hermes-engine"
37] : []).concat(use_frameworks ? [
38  "$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers/",
39  "$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/",
40  "$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
41  "$(PODS_CONFIGURATION_BUILD_DIR)/ABI49_0_0ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
42  "$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
43  "$(PODS_CONFIGURATION_BUILD_DIR)/ABI49_0_0React-RCTFabric/RCTFabric.framework/Headers/",
44  "$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers/",
45  "$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers/",
46  "$(PODS_CONFIGURATION_BUILD_DIR)/React-runtimescheduler/React_runtimescheduler.framework/Headers/",
47] : []).map{|p| "\"#{p}\""}.join(" ")
48
49Pod::Spec.new do |s|
50  s.name            = "ABI49_0_0React-RCTAppDelegate"
51  s.version                = version
52  s.summary                = "An utility library to simplify common operations for the New Architecture"
53  s.homepage               = "https://reactnative.dev/"
54  s.documentation_url      = "https://reactnative.dev/docs/actionsheetios"
55  s.license                = package["license"]
56  s.author                 = "Meta Platforms, Inc. and its affiliates"
57  s.platforms              = { :ios => "12.4" }
58  s.source                 = { :path => "." }
59  s.source_files            = "**/*.{c,h,m,mm,S,cpp}"
60
61  # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
62  s.compiler_flags = other_cflags
63  s.pod_target_xcconfig    = {
64    "HEADER_SEARCH_PATHS" => header_search_paths,
65    "OTHER_CPLUSPLUSFLAGS" => other_cflags,
66    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "DEFINES_MODULE" => "YES",
67  }
68  s.user_target_xcconfig   = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/ABI49_0_0React-Core\""}
69
70  s.dependency "ABI49_0_0React-Core"
71  s.dependency "RCT-Folly"
72  s.dependency "ABI49_0_0RCTRequired"
73  s.dependency "ABI49_0_0RCTTypeSafety"
74  s.dependency "ABI49_0_0ReactCommon/turbomodule/core"
75  s.dependency "ABI49_0_0React-RCTNetwork"
76  s.dependency "ABI49_0_0React-RCTImage"
77  s.dependency "ABI49_0_0React-NativeModulesApple"
78  s.dependency "ABI49_0_0React-CoreModules"
79  s.dependency "ABI49_0_0React-runtimescheduler"
80
81  if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
82    s.dependency "ABI49_0_0React-hermes"
83  else
84    s.dependency "ABI49_0_0React-jsc"
85  end
86
87  if is_new_arch_enabled
88    s.dependency "ABI49_0_0React-RCTFabric"
89    s.dependency "ABI49_0_0React-graphics"
90    s.dependency "ABI49_0_0React-utils"
91    s.dependency "ABI49_0_0React-debug"
92
93    s.script_phases = {
94      :name => "Generate Legacy Components Interop",
95      :script => "
96WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
97source $WITH_ENVIRONMENT
98${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{ENV['APP_PATH']} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
99      ",
100      :execution_position => :before_compile,
101      :input_files => ["#{ENV['APP_PATH']}/react-native.config.js"],
102      :output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
103    }
104  end
105end
106