react-native-macos 0.76.10 → 0.76.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/Libraries/Blob/RCTBlobManager.h +0 -0
  2. package/Libraries/Blob/RCTBlobManager.mm +0 -0
  3. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
  4. package/Libraries/Core/ReactNativeVersion.js +1 -1
  5. package/Libraries/StyleSheet/normalizeColor.js +0 -0
  6. package/React/Base/RCTJavaScriptLoader.h +0 -0
  7. package/React/Base/RCTJavaScriptLoader.mm +0 -0
  8. package/React/Base/RCTVersion.m +1 -1
  9. package/React/CoreModules/RCTLogBoxView.mm +4 -1
  10. package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +82 -14
  11. package/ReactAndroid/gradle.properties +1 -1
  12. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  13. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  14. package/local-cli/cli.js +0 -0
  15. package/package.json +3 -3
  16. package/scripts/compose-source-maps.js +0 -0
  17. package/scripts/featureflags/README.md +156 -0
  18. package/scripts/featureflags/index.js +14 -0
  19. package/scripts/ios-configure-glog.sh +0 -0
  20. package/scripts/node-binary.sh +0 -0
  21. package/scripts/packager.sh +0 -0
  22. package/scripts/react-native-xcode.sh +0 -0
  23. package/scripts/react_native_pods_utils/script_phases.sh +0 -0
  24. package/scripts/xcode/ccache-clang++.sh +0 -0
  25. package/scripts/xcode/ccache-clang.sh +0 -0
  26. package/scripts/xcode/with-environment.sh +0 -0
  27. package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +0 -2354
  28. package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +0 -2820
  29. package/scripts/cocoapods/autolinking.rb +0 -206
  30. package/scripts/cocoapods/autolinking_utils.rb +0 -25
  31. package/scripts/cocoapods/codegen.rb +0 -59
  32. package/scripts/cocoapods/codegen_script_phase_extractor.rb +0 -13
  33. package/scripts/cocoapods/codegen_utils.rb +0 -363
  34. package/scripts/cocoapods/fabric.rb +0 -18
  35. package/scripts/cocoapods/helpers.rb +0 -148
  36. package/scripts/cocoapods/jsengine.rb +0 -33
  37. package/scripts/cocoapods/local_podspec_patch.rb +0 -51
  38. package/scripts/cocoapods/new_architecture.rb +0 -193
  39. package/scripts/cocoapods/privacy_manifest_utils.rb +0 -194
  40. package/scripts/cocoapods/runtime.rb +0 -18
  41. package/scripts/cocoapods/spm.rb +0 -94
  42. package/scripts/cocoapods/utils.rb +0 -729
  43. package/scripts/codegen/codegen-utils.js +0 -51
  44. package/scripts/codegen/generate-artifacts-executor.js +0 -815
  45. package/scripts/codegen/generate-specs-cli-executor.js +0 -128
  46. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +0 -18
  47. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +0 -33
  48. package/sdks/hermes-engine/hermes-engine.podspec +0 -160
  49. package/sdks/hermes-engine/hermes-utils.rb +0 -337
  50. package/sdks/hermes-engine/utils/build-apple-framework.sh +0 -225
  51. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +0 -100
  52. package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +0 -18
  53. package/sdks/hermes-engine/utils/build-ios-framework.sh +0 -85
  54. package/sdks/hermes-engine/utils/build-mac-framework.sh +0 -22
  55. package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +0 -7
  56. package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +0 -32
  57. package/sdks/hermes-engine/utils/replace_hermes_version.js +0 -106
@@ -1,206 +0,0 @@
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
-
6
- require 'json'
7
- require 'pathname'
8
- require 'cocoapods'
9
- require_relative './autolinking_utils.rb'
10
- require_relative '../react_native_pods.rb'
11
-
12
- # Your project will have to depend on the @react-native-community/cli if you use this method
13
- # for listing React native modules.
14
- #
15
- # Parameters:
16
- # - config_command: the command to run to get the application's current config, e.g. ['npx', '@react-native-community/cli', 'config']
17
- def list_native_modules!(config_command)
18
-
19
- if !(config_command.is_a? Array and config_command.size > 0)
20
- Pod::UI.warn "Expected a list_native_modules! to be called with a config command", [
21
- "Unable to autolink if no config is provided for the current project."
22
- ]
23
- exit(1)
24
- end
25
-
26
- # Ignore stderr output, we're only interested in stdout and the return code. Libraries can output warnings to
27
- # stderr which create problems for JSON deserializing.
28
- json, _, status = Pod::Executable.capture_command(config_command[0], config_command[1..], capture: :both)
29
-
30
- if not status.success?
31
- Pod::UI.warn "The command: '#{config_command.join(" ").bold.yellow}' returned a status code of #{status.exitstatus.to_s.bold.red}", [
32
- "In order to autolink using Cocoapods, this framework uses @react-native-community/cli to discover React Native native modules",
33
- "Please either add it: yarn add -D @react-native-community/cli or consult your framework's documentation."
34
- ]
35
- exit(status.exitstatus)
36
- end
37
-
38
- config = JSON.parse(json)
39
-
40
- packages = config["dependencies"]
41
- ios_project_root = Pathname.new(config["project"]["ios"]["sourceDir"])
42
- react_native_path = Pathname.new(config["reactNativePath"])
43
- found_pods = []
44
-
45
- packages.each do |package_name, package|
46
- next unless package_config = package["platforms"]["ios"]
47
-
48
- name = package["name"]
49
- podspec_path = package_config["podspecPath"]
50
- script_phases = package_config["scriptPhases"]
51
- configurations = package_config["configurations"]
52
-
53
- # Add a warning to the queue and continue to the next dependency if the podspec_path is nil/empty
54
- if podspec_path.nil? || podspec_path.empty?
55
- Pod::UI.warn("list_native_modules! skipped the react-native dependency '#{name}'. No podspec file was found.",
56
- [
57
- "Check to see if there is an updated version that contains the necessary podspec file",
58
- "Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec",
59
- "If necessary, you can disable autolinking for the dependency and link it manually. See https://github.com/react-native-community/cli/blob/main/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library"
60
- ])
61
- next
62
- end
63
-
64
- spec = Pod::Specification.from_file(podspec_path)
65
-
66
- # Skip pods that do not support the platform of the current target.
67
- next unless AutolinkingUtils.is_platform_supported?(current_target_definition, spec)
68
-
69
- podspec_dir_path = Pathname.new(File.dirname(podspec_path))
70
-
71
- relative_path = podspec_dir_path.relative_path_from ios_project_root
72
-
73
- found_pods.push({
74
- "configurations": configurations,
75
- "name": name,
76
- "root": package["root"],
77
- "path": relative_path.to_path,
78
- "podspec_path": podspec_path,
79
- "script_phases": script_phases
80
- })
81
- end
82
-
83
- if found_pods.size > 0
84
- pods = found_pods.map { |p| p[:name] }.sort.to_sentence
85
- Pod::UI.puts "Found #{found_pods.size} #{"module".pluralize(found_pods.size)} for target `#{current_target_definition.name}`"
86
- end
87
-
88
- return {
89
- "ios_packages": found_pods,
90
- "ios_project_root_path": ios_project_root.to_s,
91
- "react_native_path": react_native_path.relative_path_from(ios_project_root).to_s
92
- }
93
- end
94
-
95
- # Your project will have to depend on the @react-native-community/cli if you use this method
96
- # for listing React native modules.
97
- #
98
- # Parameters:
99
- # - config:
100
- # - :ios_packages - Array of React Native iOS packages, e.g. [{ package_name: "Foo", package: { .. }}, ...]
101
- # - :ios_project_root_path - Absolute path to the react_native project's ios folder, e.g. /Users/foobar/project/rn_project/ios
102
- # - :react_native_path - Relative path to the react_native from the project, e.g. ./node_modules/react-native
103
- def link_native_modules!(config)
104
- Pod::UI.puts "link_native_modules! #{config}"
105
-
106
- if !(
107
- config[:ios_packages].is_a? Array and
108
- config[:ios_project_root_path].is_a? String and
109
- config[:react_native_path].is_a? String
110
- )
111
- Pod::UI.warn("link_native_modules! has been called with a malformed 'config' parameter",
112
- [
113
- "This is the config argument passed: #{config.inspect}",
114
- ]);
115
- exit(1)
116
- end
117
-
118
- ios_project_root = config[:ios_project_root_path]
119
-
120
- packages = config[:ios_packages]
121
- found_pods = []
122
-
123
- packages.each do |package|
124
- podspec_path = package[:podspec_path]
125
- configurations = package[:configurations]
126
-
127
- # Add a warning to the queue and continue to the next dependency if the podspec_path is nil/empty
128
- if podspec_path.nil? || podspec_path.empty?
129
- Pod::UI.warn("use_native_modules! skipped the react-native dependency '#{package[:name]}'. No podspec file was found.",
130
- [
131
- "Check to see if there is an updated version that contains the necessary podspec file",
132
- "Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec",
133
- "If necessary, you can disable autolinking for the dependency and link it manually. See https://github.com/react-native-community/cli/blob/main/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library"
134
- ])
135
- next
136
- end
137
-
138
- spec = Pod::Specification.from_file(podspec_path)
139
-
140
- # Don't try track packages that exclude our platforms
141
- next unless AutolinkingUtils.is_platform_supported?(current_target_definition, spec)
142
-
143
- # We want to do a look up inside the current CocoaPods target
144
- # to see if it's already included, this:
145
- # 1. Gives you the chance to define it beforehand
146
- # 2. Ensures CocoaPods won't explode if it's included twice
147
- #
148
- this_target = current_target_definition
149
- existing_deps = current_target_definition.dependencies
150
-
151
- # Skip dependencies that the user already activated themselves.
152
- next if existing_deps.find do |existing_dep|
153
- existing_dep.name.split('/').first == spec.name
154
- end
155
-
156
- podspec_dir_path = Pathname.new(File.dirname(podspec_path))
157
-
158
- relative_path = podspec_dir_path.relative_path_from ios_project_root
159
-
160
- # Register the found React Native module into our collection of Pods.
161
- pod spec.name, :path => relative_path.to_path, :configurations => configurations
162
-
163
- if package[:script_phases] && !this_target.abstract?
164
- # Can be either an object, or an array of objects
165
- Array(package[:script_phases]).each do |phase|
166
- # see https://www.rubydoc.info/gems/cocoapods-core/Pod/Podfile/DSL#script_phase-instance_method
167
- # for the full object keys
168
- Pod::UI.puts "Adding a custom script phase for Pod #{spec.name}: #{phase["name"] || 'No name specified.'}"
169
-
170
- # Support passing in a path relative to the root of the package
171
- if phase["path"]
172
- phase["script"] = File.read(File.expand_path(phase["path"], package[:root]))
173
- phase.delete("path")
174
- end
175
-
176
- # Support converting the execution position into a symbol
177
- phase["execution_position"] = phase["execution_position"]&.to_sym
178
-
179
- phase = Hash[phase.map { |k, v| [k.to_sym, v] }]
180
- script_phase phase
181
- end
182
- end
183
-
184
- found_pods.push spec
185
- end
186
-
187
- if found_pods.size > 0
188
- pods = found_pods.map { |p| p.name }.sort.to_sentence
189
- Pod::UI.puts "Auto-linking React Native #{"module".pluralize(found_pods.size)} for target `#{current_target_definition.name}`: #{pods}"
190
- end
191
-
192
- return {
193
- :reactNativePath => config[:react_native_path]
194
- }
195
- end
196
-
197
- $default_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
198
-
199
- # Autolink your native modules
200
- #
201
- # Parameters:
202
- # - config_command: the command to run to get the application's current config, e.g. ['npx', '@react-native-community/cli', 'config'],
203
- # you can override this if you'd like to avoid the dependency. e.g. ['cat', 'your_config.json']
204
- def use_native_modules!(config_command = $default_command)
205
- return link_native_modules!(list_native_modules!(config_command))
206
- end
@@ -1,25 +0,0 @@
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
-
6
- class AutolinkingUtils
7
-
8
- def self.nested_path_exists?(object, *path)
9
- path.reduce(object) do |obj, method|
10
- return false unless obj.respond_to?(method)
11
- obj.public_send(method)
12
- end
13
- return true
14
- end
15
-
16
- def self.is_platform_supported?(current_target_definition, spec)
17
- platform = current_target_definition.platform
18
- if !platform
19
- # Historically we've supported platforms that aren't specifically excluded.
20
- return true
21
- end
22
- return spec.supported_on_platform?(platform.name)
23
- end
24
-
25
- end
@@ -1,59 +0,0 @@
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
-
6
- require_relative './helpers.rb'
7
-
8
- # It builds the codegen CLI if it is not present
9
- #
10
- # Parameters:
11
- # - react_native_path: the path to the react native installation
12
- # - relative_installation_root: the path to the relative installation root of the pods
13
- # - dir_manager: a class that implements the `Dir` interface. Defaults to `Dir`, the Dependency can be injected for testing purposes.
14
- # @throws an error if it could not find the codegen folder.
15
- def build_codegen!(react_native_path, relative_installation_root, dir_manager: Dir)
16
- codegen_repo_path = "#{basePath(react_native_path, relative_installation_root)}/../react-native-codegen"
17
- return unless dir_manager.exist?(codegen_repo_path) && !dir_manager.exist?("#{codegen_repo_path}/lib")
18
-
19
- Pod::UI.puts "[Codegen] building #{codegen_repo_path}"
20
- system("#{codegen_repo_path}/scripts/oss/build.sh")
21
- end
22
-
23
- # keeping the run_codegen! method for testing purposes
24
- def run_codegen!(
25
- app_path,
26
- config_file_dir,
27
- new_arch_enabled: false,
28
- disable_codegen: false,
29
- react_native_path: "../node_modules/react-native",
30
- fabric_enabled: false,
31
- hermes_enabled: true,
32
- codegen_output_dir: 'build/generated/ios',
33
- config_key: 'codegenConfig',
34
- package_json_file: '~/app/package.json',
35
- folly_version: Helpers::Constants.folly_config()[:version],
36
- codegen_utils: CodegenUtils.new()
37
- )
38
-
39
- codegen_utils.use_react_native_codegen_discovery!(
40
- disable_codegen,
41
- app_path,
42
- :react_native_path => react_native_path,
43
- :fabric_enabled => fabric_enabled,
44
- :hermes_enabled => hermes_enabled,
45
- :config_file_dir => config_file_dir,
46
- :codegen_output_dir => codegen_output_dir,
47
- :config_key => config_key,
48
- :folly_version => folly_version
49
- )
50
- end
51
-
52
- def basePath(react_native_path, relative_installation_root)
53
- expanded_path = File.expand_path(react_native_path)
54
- if expanded_path == react_native_path
55
- react_native_path
56
- else
57
- File.join(relative_installation_root.to_s, react_native_path)
58
- end
59
- end
@@ -1,13 +0,0 @@
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
-
6
- class CodegenScriptPhaseExtractor
7
- def initialize()
8
- end
9
-
10
- def extract_script_phase(options)
11
- get_script_phases_with_codegen_discovery(options)
12
- end
13
- end
@@ -1,363 +0,0 @@
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
-
6
- require 'json'
7
- require_relative './utils.rb'
8
- require_relative './helpers.rb'
9
- require_relative './codegen_script_phase_extractor.rb'
10
-
11
- class CodegenUtils
12
-
13
- def initialize()
14
- end
15
-
16
- @@REACT_CODEGEN_PODSPEC_GENERATED = false
17
-
18
- def self.set_react_codegen_podspec_generated(value)
19
- @@REACT_CODEGEN_PODSPEC_GENERATED = value
20
- end
21
-
22
- def self.react_codegen_podspec_generated
23
- @@REACT_CODEGEN_PODSPEC_GENERATED
24
- end
25
-
26
- @@REACT_CODEGEN_DISCOVERY_DONE = false
27
-
28
- def self.set_react_codegen_discovery_done(value)
29
- @@REACT_CODEGEN_DISCOVERY_DONE = value
30
- end
31
-
32
- def self.react_codegen_discovery_done
33
- @@REACT_CODEGEN_DISCOVERY_DONE
34
- end
35
-
36
- # It takes some cocoapods specs and writes them into a file
37
- #
38
- # Parameters
39
- # - spec: the cocoapod specs
40
- # - codegen_output_dir: the output directory for the codegen
41
- # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
42
- def generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: File)
43
- # This podspec file should only be create once in the session/pod install.
44
- # This happens when multiple targets are calling use_react_native!.
45
- if @@REACT_CODEGEN_PODSPEC_GENERATED
46
- Pod::UI.puts "[Codegen] Skipping ReactCodegen podspec generation."
47
- return
48
- end
49
-
50
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
51
- output_dir = "#{relative_installation_root}/#{codegen_output_dir}"
52
- Pod::Executable.execute_command("mkdir", ["-p", output_dir]);
53
-
54
- podspec_path = file_manager.join(output_dir, 'ReactCodegen.podspec.json')
55
- Pod::UI.puts "[Codegen] Generating #{podspec_path}"
56
-
57
- file_manager.open(podspec_path, 'w') do |f|
58
- f.write(spec.to_json)
59
- f.fsync
60
- end
61
-
62
- @@REACT_CODEGEN_PODSPEC_GENERATED = true
63
- end
64
-
65
- # It generates the podspec object that represents the `ReactCodegen.podspec` file
66
- #
67
- # Parameters
68
- # - package_json_file: the path to the `package.json`, required to extract the proper React Native version
69
- # - hermes_enabled: whether hermes is enabled or not.
70
- # - script_phases: whether we want to add some build script phases or not.
71
- # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
72
- def get_react_codegen_spec(package_json_file, folly_version: get_folly_config()[:version], hermes_enabled: true, script_phases: nil, file_manager: File)
73
- package = JSON.parse(file_manager.read(package_json_file))
74
- version = package['version']
75
- use_frameworks = ENV['USE_FRAMEWORKS'] != nil
76
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -Wno-comma -Wno-shorten-64-to-32'
77
- boost_compiler_flags = '-Wno-documentation'
78
-
79
- header_search_paths = [
80
- "\"$(PODS_ROOT)/boost\"",
81
- "\"$(PODS_ROOT)/RCT-Folly\"",
82
- "\"$(PODS_ROOT)/DoubleConversion\"",
83
- "\"$(PODS_ROOT)/fast_float/include\"",
84
- "\"$(PODS_ROOT)/fmt/include\"",
85
- "\"${PODS_ROOT}/Headers/Public/ReactCodegen/react/renderer/components\"",
86
- "\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
87
- "\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
88
- "\"$(PODS_ROOT)/Headers/Private/Yoga\"",
89
- "\"$(PODS_TARGET_SRCROOT)\"",
90
- ]
91
- framework_search_paths = []
92
-
93
- if use_frameworks
94
- ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-Fabric", "React_Fabric", ["react/renderer/components/view/platform/cxx"])
95
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-FabricImage", "React_FabricImage", []))
96
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-graphics", "React_graphics", ["react/renderer/graphics/platform/ios"]))
97
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "ReactCommon", "ReactCommon", ["react/nativemodule/core"]))
98
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-NativeModulesApple", "React_NativeModulesApple", []))
99
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-RCTFabric", "RCTFabric", []))
100
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-debug", "React_debug", []))
101
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-rendererdebug", "React_rendererdebug", []))
102
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-utils", "React_utils", []))
103
- .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-featureflags", "React_featureflags", []))
104
- .each { |search_path|
105
- header_search_paths << "\"#{search_path}\""
106
- }
107
- end
108
-
109
- spec = {
110
- 'name' => "ReactCodegen",
111
- 'version' => version,
112
- 'summary' => 'Temp pod for generated files for React Native',
113
- 'homepage' => 'https://facebook.com/',
114
- 'license' => 'Unlicense',
115
- 'authors' => 'Facebook',
116
- 'compiler_flags' => "#{folly_compiler_flags} #{boost_compiler_flags} -Wno-nullability-completeness -std=c++20",
117
- 'source' => { :git => '' },
118
- 'header_mappings_dir' => './',
119
- 'platforms' => min_supported_versions,
120
- 'source_files' => "**/*.{h,mm,cpp}",
121
- 'pod_target_xcconfig' => {
122
- "HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
123
- "FRAMEWORK_SEARCH_PATHS" => framework_search_paths
124
- },
125
- 'dependencies': {
126
- "React-jsiexecutor": [],
127
- "RCT-Folly": [],
128
- "RCTRequired": [],
129
- "RCTTypeSafety": [],
130
- "React-Core": [],
131
- "React-jsi": [],
132
- "ReactCommon/turbomodule/bridging": [],
133
- "ReactCommon/turbomodule/core": [],
134
- "React-NativeModulesApple": [],
135
- "glog": [],
136
- "DoubleConversion": [],
137
- 'React-graphics': [],
138
- 'React-rendererdebug': [],
139
- 'React-Fabric': [],
140
- 'React-FabricImage': [],
141
- 'React-debug': [],
142
- 'React-utils': [],
143
- 'React-featureflags': [],
144
- }
145
- }
146
-
147
- if hermes_enabled
148
- spec[:'dependencies'].merge!({
149
- 'hermes-engine': [],
150
- });
151
- else
152
- spec[:'dependencies'].merge!({
153
- 'React-jsc': [],
154
- });
155
- end
156
-
157
- if script_phases
158
- Pod::UI.puts "[Codegen] Adding script_phases to ReactCodegen."
159
- spec[:'script_phases'] = script_phases
160
- end
161
-
162
- return spec
163
- end
164
-
165
- # It extracts the codegen config from the configuration file
166
- #
167
- # Parameters
168
- # - config_path: a path to the configuration file
169
- # - config_key: the codegen configuration key
170
- # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
171
- #
172
- # Returns: the list of dependencies as extracted from the package.json
173
- def get_codegen_config_from_file(config_path, config_key, file_manager: File)
174
- empty = {}
175
- if !file_manager.exist?(config_path)
176
- return empty
177
- end
178
-
179
- config = JSON.parse(file_manager.read(config_path))
180
- return config[config_key] ? config[config_key] : empty
181
- end
182
-
183
- # It creates a list of JS files that contains the JS specifications that Codegen needs to use to generate the code
184
- #
185
- # Parameters
186
- # - app_codegen_config: an object that contains the configurations
187
- # - app_path: path to the app
188
- # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
189
- #
190
- # Returns: the list of files that needs to be used by Codegen
191
- def get_list_of_js_specs(app_codegen_config, app_path, file_manager: File)
192
- file_list = []
193
-
194
- if app_codegen_config['libraries'] then
195
- Pod::UI.warn '[Deprecated] You are using the old `libraries` array to list all your codegen.\nThis method will be removed in the future.\nUpdate your `package.json` with a single object.'
196
- app_codegen_config['libraries'].each do |library|
197
- library_dir = file_manager.join(app_path, library['jsSrcsDir'])
198
- file_list.concat(Finder.find_codegen_file(library_dir))
199
- end
200
- elsif app_codegen_config['jsSrcsDir'] then
201
- codegen_dir = file_manager.join(app_path, app_codegen_config['jsSrcsDir'])
202
- file_list.concat (Finder.find_codegen_file(codegen_dir))
203
- end
204
-
205
- input_files = file_list.map { |filename| "${PODS_ROOT}/../#{Pathname.new(filename).realpath().relative_path_from(Pod::Config.instance.installation_root)}" }
206
-
207
- return input_files
208
- end
209
-
210
- # It generates the build script phase for the codegen
211
- #
212
- # Parameters
213
- # - app_path: the path to the app
214
- # - fabric_enabled: whether fabric is enabled or not
215
- # - config_file_dir: the directory of the config file
216
- # - react_native_path: the path to React Native
217
- # - config_key: the configuration key to use in the package.json for the Codegen
218
- # - codegen_utils: an object which exposes utilities functions for the codegen
219
- # - script_phase_extractor: an object that is able to extract the Xcode Script Phases for React Native
220
- # - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
221
- #
222
- # Return: an object containing the script phase
223
- def get_react_codegen_script_phases(
224
- app_path,
225
- fabric_enabled: false,
226
- hermes_enabled: false,
227
- config_file_dir: '',
228
- react_native_path: "../node_modules/react-native",
229
- config_key: 'codegenConfig',
230
- codegen_utils: CodegenUtils.new(),
231
- script_phase_extractor: CodegenScriptPhaseExtractor.new(),
232
- file_manager: File
233
- )
234
- if !app_path
235
- Pod::UI.warn '[Codegen] error: app_path is required to use codegen discovery.'
236
- abort
237
- end
238
-
239
- # We need to convert paths to relative path from installation_root for the script phase for CI.
240
- relative_app_root = Pathname.new(app_path).realpath().relative_path_from(Pod::Config.instance.installation_root)
241
-
242
- relative_config_file_dir = ''
243
- if config_file_dir != ''
244
- relative_config_file_dir = Pathname.new(config_file_dir).relative_path_from(Pod::Config.instance.installation_root)
245
- end
246
-
247
- # Generate input files for in-app libaraies which will be used to check if the script needs to be run.
248
- # TODO: Ideally, we generate the input_files list from generate-codegen-artifacts.js and read the result here.
249
- # Or, generate this podspec in generate-codegen-artifacts.js as well.
250
- app_package_path = file_manager.join(app_path, 'package.json')
251
- app_codegen_config = codegen_utils.get_codegen_config_from_file(app_package_path, config_key)
252
- input_files = codegen_utils.get_list_of_js_specs(app_codegen_config, app_path)
253
-
254
- # Add a script phase to trigger generate artifact.
255
- # Some code is duplicated so that it's easier to delete the old way and switch over to this once it's stabilized.
256
- return {
257
- 'name': 'Generate Specs',
258
- 'execution_position': :before_compile,
259
- 'input_files' => input_files,
260
- 'show_env_vars_in_log': true,
261
- 'output_files': ["${DERIVED_FILE_DIR}/react-codegen.log"],
262
- 'script': script_phase_extractor.extract_script_phase(
263
- react_native_path: react_native_path,
264
- relative_app_root: relative_app_root,
265
- relative_config_file_dir: relative_config_file_dir,
266
- fabric_enabled: fabric_enabled
267
- ),
268
- }
269
- end
270
-
271
- def use_react_native_codegen_discovery!(
272
- codegen_disabled,
273
- app_path,
274
- react_native_path: "../node_modules/react-native",
275
- fabric_enabled: false,
276
- hermes_enabled: true,
277
- config_file_dir: '',
278
- codegen_output_dir: 'build/generated/ios',
279
- config_key: 'codegenConfig',
280
- folly_version: get_folly_config()[:version],
281
- codegen_utils: CodegenUtils.new(),
282
- file_manager: File
283
- )
284
- return if codegen_disabled
285
-
286
- if CodegenUtils.react_codegen_discovery_done()
287
- Pod::UI.puts "[Codegen] Skipping use_react_native_codegen_discovery."
288
- return
289
- end
290
-
291
- if !app_path
292
- Pod::UI.warn '[Codegen] Error: app_path is required for use_react_native_codegen_discovery.'
293
- Pod::UI.warn '[Codegen] If you are calling use_react_native_codegen_discovery! in your Podfile, please remove the call and pass `app_path` and/or `config_file_dir` to `use_react_native!`.'
294
- abort
295
- end
296
-
297
- Pod::UI.warn '[Codegen] warn: using experimental new codegen integration'
298
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
299
-
300
- # Generate ReactCodegen podspec here to add the script phases.
301
- script_phases = codegen_utils.get_react_codegen_script_phases(
302
- app_path,
303
- :fabric_enabled => fabric_enabled,
304
- :config_file_dir => config_file_dir,
305
- :react_native_path => react_native_path,
306
- :config_key => config_key
307
- )
308
- react_codegen_spec = codegen_utils.get_react_codegen_spec(
309
- file_manager.join(relative_installation_root, react_native_path, "package.json"),
310
- :folly_version => folly_version,
311
- :hermes_enabled => hermes_enabled,
312
- :script_phases => script_phases
313
- )
314
- codegen_utils.generate_react_codegen_podspec!(react_codegen_spec, codegen_output_dir)
315
-
316
- out = Pod::Executable.execute_command(
317
- 'node',
318
- [
319
- "#{relative_installation_root}/#{react_native_path}/scripts/generate-codegen-artifacts.js",
320
- "-p", "#{app_path}",
321
- "-o", Pod::Config.instance.installation_root,
322
- "-t", "ios",
323
- ])
324
- Pod::UI.puts out;
325
-
326
- CodegenUtils.set_react_codegen_discovery_done(true)
327
- end
328
-
329
- @@CLEANUP_DONE = false
330
-
331
- def self.set_cleanup_done(newValue)
332
- @@CLEANUP_DONE = newValue
333
- end
334
-
335
- def self.cleanup_done
336
- return @@CLEANUP_DONE
337
- end
338
-
339
- def self.clean_up_build_folder(rn_path, codegen_dir, dir_manager: Dir, file_manager: File)
340
- return if CodegenUtils.cleanup_done()
341
- CodegenUtils.set_cleanup_done(true)
342
-
343
- ios_folder = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
344
- codegen_path = file_manager.join(ios_folder, codegen_dir)
345
- return if !dir_manager.exist?(codegen_path)
346
-
347
- FileUtils.rm_rf(dir_manager.glob("#{codegen_path}/*"))
348
- base_provider_path = file_manager.join(rn_path, 'React', 'Fabric', 'RCTThirdPartyFabricComponentsProvider')
349
- FileUtils.rm_rf("#{base_provider_path}.h")
350
- FileUtils.rm_rf("#{base_provider_path}.mm")
351
- CodegenUtils.assert_codegen_folder_is_empty(codegen_path, dir_manager: dir_manager)
352
- end
353
-
354
- # Need to split this function from the previous one to be able to test it properly.
355
- def self.assert_codegen_folder_is_empty(codegen_path, dir_manager: Dir)
356
- # double check that the files have actually been deleted.
357
- # Emit an error message if not.
358
- if dir_manager.exist?(codegen_path) && dir_manager.glob("#{codegen_path}/*").length() != 0
359
- Pod::UI.warn "Unable to remove the content of #{codegen_path} folder. Please run rm -rf #{codegen_path} and try again."
360
- abort
361
- end
362
- end
363
- end