react-native-macos 0.76.11 → 0.76.12

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 (53) 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/ReactAndroid/gradle.properties +1 -1
  10. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  11. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  12. package/local-cli/cli.js +0 -0
  13. package/package.json +3 -3
  14. package/scripts/cocoapods/autolinking.rb +206 -0
  15. package/scripts/cocoapods/autolinking_utils.rb +25 -0
  16. package/scripts/cocoapods/codegen.rb +59 -0
  17. package/scripts/cocoapods/codegen_script_phase_extractor.rb +13 -0
  18. package/scripts/cocoapods/codegen_utils.rb +363 -0
  19. package/scripts/cocoapods/fabric.rb +18 -0
  20. package/scripts/cocoapods/helpers.rb +148 -0
  21. package/scripts/cocoapods/jsengine.rb +33 -0
  22. package/scripts/cocoapods/local_podspec_patch.rb +51 -0
  23. package/scripts/cocoapods/new_architecture.rb +193 -0
  24. package/scripts/cocoapods/privacy_manifest_utils.rb +194 -0
  25. package/scripts/cocoapods/runtime.rb +18 -0
  26. package/scripts/cocoapods/spm.rb +94 -0
  27. package/scripts/cocoapods/utils.rb +729 -0
  28. package/scripts/codegen/codegen-utils.js +51 -0
  29. package/scripts/codegen/generate-artifacts-executor.js +815 -0
  30. package/scripts/codegen/generate-specs-cli-executor.js +128 -0
  31. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +18 -0
  32. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +33 -0
  33. package/scripts/compose-source-maps.js +0 -0
  34. package/scripts/ios-configure-glog.sh +0 -0
  35. package/scripts/node-binary.sh +0 -0
  36. package/scripts/packager.sh +0 -0
  37. package/scripts/react-native-xcode.sh +0 -0
  38. package/scripts/react_native_pods_utils/script_phases.sh +0 -0
  39. package/scripts/xcode/ccache-clang++.sh +0 -0
  40. package/scripts/xcode/ccache-clang.sh +0 -0
  41. package/scripts/xcode/with-environment.sh +0 -0
  42. package/sdks/hermes-engine/hermes-engine.podspec +160 -0
  43. package/sdks/hermes-engine/hermes-utils.rb +337 -0
  44. package/sdks/hermes-engine/utils/build-apple-framework.sh +225 -0
  45. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +100 -0
  46. package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +18 -0
  47. package/sdks/hermes-engine/utils/build-ios-framework.sh +85 -0
  48. package/sdks/hermes-engine/utils/build-mac-framework.sh +22 -0
  49. package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +7 -0
  50. package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +32 -0
  51. package/sdks/hermes-engine/utils/replace_hermes_version.js +106 -0
  52. package/scripts/featureflags/README.md +0 -156
  53. package/scripts/featureflags/index.js +0 -14
@@ -0,0 +1,729 @@
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 'shellwords'
7
+
8
+ require_relative "./helpers.rb"
9
+
10
+ # Utilities class for React Native Cocoapods
11
+ class ReactNativePodsUtils
12
+ def self.warn_if_not_on_arm64
13
+ if SysctlChecker.new().call_sysctl_arm64() == 1 && !Environment.new().ruby_platform().include?('arm64')
14
+ Pod::UI.warn 'Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).'
15
+ Pod::UI.warn ' - Emulated x86_64 is slower than native arm64'
16
+ Pod::UI.warn ' - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)'
17
+ Pod::UI.warn 'Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.'
18
+ end
19
+ end
20
+
21
+ # deprecated. These checks are duplicated in the react_native_pods function
22
+ # and we don't really need them. Removing this function will make it easy to
23
+ # move forward.
24
+ def self.get_default_flags
25
+ flags = {
26
+ :fabric_enabled => false,
27
+ :hermes_enabled => true,
28
+ }
29
+
30
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
31
+ flags[:fabric_enabled] = true
32
+ flags[:hermes_enabled] = true
33
+ end
34
+
35
+ if ENV['USE_HERMES'] == '0'
36
+ flags[:hermes_enabled] = false
37
+ end
38
+
39
+ return flags
40
+ end
41
+
42
+ def self.has_pod(installer, name)
43
+ installer.pods_project.pod_group(name) != nil
44
+ end
45
+
46
+ def self.set_gcc_preprocessor_definition_for_React_hermes(installer)
47
+ self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-hermes", :debug)
48
+ self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-jsinspector", :debug)
49
+ self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "hermes-engine", :debug)
50
+ self.add_build_settings_to_pod(installer, "GCC_PREPROCESSOR_DEFINITIONS", "HERMES_ENABLE_DEBUGGER=1", "React-RuntimeHermes", :debug)
51
+ end
52
+
53
+ def self.turn_off_resource_bundle_react_core(installer)
54
+ # this is needed for Xcode 14, see more details here https://github.com/facebook/react-native/issues/34673
55
+ # we should be able to remove this once CocoaPods catches up to it, see more details here https://github.com/CocoaPods/CocoaPods/issues/11402
56
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
57
+ if pod_name.to_s == 'React-Core'
58
+ target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
59
+ resource_bundle_target.build_configurations.each do |config|
60
+ config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ def self.set_build_setting(installer, build_setting:, value:, config_name: nil)
68
+ Pod::UI.puts("Setting #{build_setting} build settings")
69
+ projects = self.extract_projects(installer)
70
+
71
+ projects.each do |project|
72
+ project.build_configurations.each do |config|
73
+ if config_name == nil || config.name == config_name
74
+ config.build_settings[build_setting] = value
75
+ end
76
+ end
77
+
78
+ project.save()
79
+ end
80
+ end
81
+
82
+ def self.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled)
83
+ projects = self.extract_projects(installer)
84
+
85
+ ccache_path = `command -v ccache`.strip
86
+ ccache_available = !ccache_path.empty?
87
+
88
+ message_prefix = "[Ccache]"
89
+
90
+ if ccache_available
91
+ Pod::UI.puts("#{message_prefix}: Ccache found at #{ccache_path}")
92
+ end
93
+
94
+ # Using scripts wrapping the ccache executable, to allow injection of configurations
95
+ ccache_clang_sh = File.join("$(REACT_NATIVE_PATH)", 'scripts', 'xcode', 'ccache-clang.sh')
96
+ ccache_clangpp_sh = File.join("$(REACT_NATIVE_PATH)", 'scripts', 'xcode', 'ccache-clang++.sh')
97
+
98
+ if ccache_available and ccache_enabled
99
+ Pod::UI.puts("#{message_prefix}: Setting CC, LD, CXX & LDPLUSPLUS build settings")
100
+
101
+ projects.each do |project|
102
+ project.build_configurations.each do |config|
103
+ # Using the un-qualified names means you can swap in different implementations, for example ccache
104
+ config.build_settings["CC"] = ccache_clang_sh
105
+ config.build_settings["LD"] = ccache_clang_sh
106
+ config.build_settings["CXX"] = ccache_clangpp_sh
107
+ config.build_settings["LDPLUSPLUS"] = ccache_clangpp_sh
108
+ end
109
+
110
+ project.save()
111
+ end
112
+ elsif ccache_available and !ccache_enabled
113
+ Pod::UI.puts("#{message_prefix}: Pass ':ccache_enabled => true' to 'react_native_post_install' in your Podfile or set environment variable 'USE_CCACHE=1' to increase the speed of subsequent builds")
114
+ elsif !ccache_available and ccache_enabled
115
+ Pod::UI.warn("#{message_prefix}: Install ccache or ensure your neither passing ':ccache_enabled => true' nor setting environment variable 'USE_CCACHE=1'")
116
+ else
117
+ Pod::UI.puts("#{message_prefix}: Removing Ccache from CC, LD, CXX & LDPLUSPLUS build settings")
118
+
119
+ projects.each do |project|
120
+ project.build_configurations.each do |config|
121
+ # Using the un-qualified names means you can swap in different implementations, for example ccache
122
+ config.build_settings["CC"] = config.build_settings["CC"].gsub(/#{Regexp.escape(ccache_clang_sh)}/, '') if config.build_settings["CC"]
123
+ config.build_settings["LD"] = config.build_settings["LD"].gsub(/#{Regexp.escape(ccache_clang_sh)}/, "") if config.build_settings["LD"]
124
+ config.build_settings["CXX"] = config.build_settings["CXX"].gsub(/#{Regexp.escape(ccache_clangpp_sh)}/, "") if config.build_settings["CXX"]
125
+ config.build_settings["LDPLUSPLUS"] = config.build_settings["LDPLUSPLUS"].gsub(/#{Regexp.escape(ccache_clangpp_sh)}/, "") if config.build_settings["LDPLUSPLUS"]
126
+ end
127
+
128
+ project.save()
129
+ end
130
+ end
131
+ end
132
+
133
+ def self.fix_library_search_paths(installer)
134
+ projects = self.extract_projects(installer)
135
+
136
+ projects.each do |project|
137
+ project.build_configurations.each do |config|
138
+ self.fix_library_search_path(config)
139
+ end
140
+ project.native_targets.each do |target|
141
+ target.build_configurations.each do |config|
142
+ self.fix_library_search_path(config)
143
+ end
144
+ end
145
+ project.save()
146
+ end
147
+ end
148
+
149
+ def self.apply_mac_catalyst_patches(installer)
150
+ # Fix bundle signing issues
151
+ installer.pods_project.targets.each do |target|
152
+ if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
153
+ target.build_configurations.each do |config|
154
+ config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-'
155
+ end
156
+ end
157
+ end
158
+
159
+ installer.aggregate_targets.each do |aggregate_target|
160
+ aggregate_target.user_project.native_targets.each do |target|
161
+ target.build_configurations.each do |config|
162
+ # Explicitly set dead code stripping flags
163
+ config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
164
+ config.build_settings['PRESERVE_DEAD_CODE_INITS_AND_TERMS'] = 'YES'
165
+ # Modify library search paths
166
+ config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(SDKROOT)/System/iOSSupport/usr/lib/swift', '$(inherited)']
167
+ end
168
+ end
169
+ aggregate_target.user_project.save()
170
+ end
171
+ end
172
+
173
+ def self.apply_xcode_15_patch(installer, xcodebuild_manager: Xcodebuild)
174
+ projects = self.extract_projects(installer)
175
+
176
+ other_ld_flags_key = 'OTHER_LDFLAGS'
177
+ xcode15_compatibility_flags = '-Wl -ld_classic '
178
+
179
+ projects.each do |project|
180
+ project.build_configurations.each do |config|
181
+ # fix for weak linking
182
+ self.safe_init(config, other_ld_flags_key)
183
+ if self.is_using_xcode15_0(:xcodebuild_manager => xcodebuild_manager)
184
+ self.add_value_to_setting_if_missing(config, other_ld_flags_key, xcode15_compatibility_flags)
185
+ else
186
+ self.remove_value_from_setting_if_present(config, other_ld_flags_key, xcode15_compatibility_flags)
187
+ end
188
+ end
189
+ project.save()
190
+ end
191
+
192
+ end
193
+
194
+ private
195
+
196
+ def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration_type)
197
+ # [macOS
198
+ # Since some RN projects might combine multiple platforms into the same Xcode project,
199
+ # we'll be much more forgiving with the pod name matching in react-native-macos.
200
+ # Could be upstreamed as part of https://github.com/microsoft/react-native-macos/issues/2526.
201
+ valid_suffixes = ["", "-iOS", "-macOS", "-visionOS"]
202
+ # macOS]
203
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
204
+ if valid_suffixes.any? { |suffix| pod_name.to_s == "#{target_pod_name}#{suffix}" } # [macOS]
205
+ target_installation_result.native_target.build_configurations.each do |config|
206
+ if configuration_type == nil || (configuration_type != nil && config.type == configuration_type)
207
+ config.build_settings[settings_name] ||= '$(inherited) '
208
+ config.build_settings[settings_name] << settings_value
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ def self.fix_library_search_path(config)
216
+ lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
217
+
218
+ if lib_search_paths == nil
219
+ # No search paths defined, return immediately
220
+ return
221
+ end
222
+
223
+ if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
224
+ # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple Silicon)
225
+ # since the libraries there are only built for x86_64 and i386.
226
+ lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
227
+ lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
228
+ end
229
+
230
+ if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
231
+ # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
232
+ lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
233
+ end
234
+ end
235
+
236
+ def self.create_xcode_env_if_missing(file_manager: File)
237
+ relative_path = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
238
+ file_path = file_manager.join(relative_path, '.xcode.env')
239
+
240
+ if !file_manager.exist?(file_path)
241
+ system("echo 'export NODE_BINARY=$(command -v node)' > #{file_path}")
242
+ end
243
+
244
+ if !file_manager.exist?("#{file_path}.local")
245
+ # When installing pods with a yarn alias, yarn creates a fake yarn and node executables
246
+ # in a temporary folder.
247
+ # Using `node --print "process.argv[0]";` we are able to retrieve the actual path from which node is running.
248
+ # see https://github.com/facebook/react-native/issues/43285 for more info. We've tweaked this slightly.
249
+ node_binary = Shellwords.escape(`node --print "process.argv[0]"`.strip)
250
+ system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
251
+ end
252
+ end
253
+
254
+ # It examines the target_definition property and sets the appropriate value for
255
+ # ENV['USE_FRAMEWORKS'] variable.
256
+ #
257
+ # - parameter target_definition: The current target definition
258
+ def self.detect_use_frameworks(target_definition)
259
+ if ENV['USE_FRAMEWORKS'] != nil
260
+ return
261
+ end
262
+
263
+ framework_build_type = target_definition.build_type.to_s
264
+
265
+ Pod::UI.puts("Framework build type is #{framework_build_type}")
266
+
267
+ if framework_build_type === "static framework"
268
+ ENV['USE_FRAMEWORKS'] = 'static'
269
+ elsif framework_build_type === "dynamic framework"
270
+ ENV['USE_FRAMEWORKS'] = 'dynamic'
271
+ else
272
+ ENV['USE_FRAMEWORKS'] = nil
273
+ end
274
+ end
275
+
276
+ def self.create_header_search_path_for_frameworks(base_folder, pod_name, framework_name, additional_paths, include_base_path = true)
277
+ platforms = $RN_PLATFORMS != nil ? $RN_PLATFORMS : []
278
+ search_paths = []
279
+
280
+ if platforms.empty?() || platforms.length() == 1
281
+ base_path = File.join("${#{base_folder}}", pod_name, "#{framework_name}.framework", "Headers")
282
+ self.add_search_path_to_result(search_paths, base_path, additional_paths, include_base_path)
283
+ else
284
+ platforms.each { |platform|
285
+ base_path = File.join("${#{base_folder}}", "#{pod_name}-#{platform}", "#{framework_name}.framework", "Headers")
286
+ self.add_search_path_to_result(search_paths, base_path, additional_paths, include_base_path)
287
+ }
288
+ end
289
+ return search_paths
290
+ end
291
+
292
+ # Add a new dependency to an existing spec, configuring also the headers search paths
293
+ def self.add_dependency(spec, dependency_name, base_folder_for_frameworks, framework_name, additional_paths: [], version: nil, subspec_dependency: nil)
294
+ # Update Search Path
295
+ optional_current_search_path = spec.to_hash["pod_target_xcconfig"]["HEADER_SEARCH_PATHS"]
296
+ current_search_paths = (optional_current_search_path != nil ? optional_current_search_path : "")
297
+ .split(" ")
298
+ create_header_search_path_for_frameworks(base_folder_for_frameworks, dependency_name, framework_name, additional_paths)
299
+ .each { |path|
300
+ wrapped_path = "\"#{path}\""
301
+ current_search_paths << wrapped_path
302
+ }
303
+ current_pod_target_xcconfig = spec.to_hash["pod_target_xcconfig"]
304
+ current_pod_target_xcconfig["HEADER_SEARCH_PATHS"] = current_search_paths.join(" ")
305
+ spec.pod_target_xcconfig = current_pod_target_xcconfig
306
+
307
+ actual_dependency = subspec_dependency != nil ? "#{dependency_name}/#{subspec_dependency}" : dependency_name
308
+ # Set Dependency
309
+ if !version
310
+ spec.dependency actual_dependency
311
+ else
312
+ spec.dependency actual_dependency, version
313
+ end
314
+ end
315
+
316
+ def self.update_search_paths(installer)
317
+ return if ENV['USE_FRAMEWORKS'] == nil
318
+
319
+ projects = self.extract_projects(installer)
320
+
321
+ projects.each do |project|
322
+ project.build_configurations.each do |config|
323
+
324
+ header_search_paths = config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited)"
325
+
326
+ ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "ReactCommon", "ReactCommon", ["react/nativemodule/core"])
327
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "ReactCommon-Samples", "ReactCommon_Samples", ["platform/ios"]))
328
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-Fabric", "React_Fabric", ["react/renderer/components/view/platform/cxx"], false))
329
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-NativeModulesApple", "React_NativeModulesApple", []))
330
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-graphics", "React_graphics", ["react/renderer/graphics/platform/ios"]))
331
+ .each{ |search_path|
332
+ header_search_paths = self.add_search_path_if_not_included(header_search_paths, search_path)
333
+ }
334
+
335
+ config.build_settings["HEADER_SEARCH_PATHS"] = header_search_paths
336
+ end
337
+
338
+ project.save()
339
+ end
340
+
341
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
342
+ if self.react_native_pods.include?(pod_name) || pod_name.include?("Pod") || pod_name.include?("Tests")
343
+ next
344
+ end
345
+
346
+ self.set_rctfolly_search_paths(target_installation_result)
347
+ self.set_codegen_search_paths(target_installation_result)
348
+ self.set_reactcommon_searchpaths(target_installation_result)
349
+ self.set_rctfabric_search_paths(target_installation_result)
350
+ self.set_imagemanager_search_path(target_installation_result)
351
+ end
352
+ end
353
+
354
+ def self.updateOSDeploymentTarget(installer)
355
+ installer.target_installation_results.pod_target_installation_results
356
+ .each do |pod_name, target_installation_result|
357
+ target_installation_result.native_target.build_configurations.each do |config|
358
+ old_iphone_deploy_target = config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] ?
359
+ config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] :
360
+ Helpers::Constants.min_ios_version_supported
361
+ config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = [Helpers::Constants.min_ios_version_supported.to_f, old_iphone_deploy_target.to_f].max.to_s
362
+ # [macOS
363
+ old_macos_deploy_target = config.build_settings["MACOSX_DEPLOYMENT_TARGET"] ?
364
+ config.build_settings["MACOSX_DEPLOYMENT_TARGET"] :
365
+ Helpers::Constants.min_macos_version_supported
366
+ config.build_settings["MACOSX_DEPLOYMENT_TARGET"] = [Helpers::Constants.min_macos_version_supported.to_f, old_macos_deploy_target.to_f].max.to_s
367
+ # macOS]
368
+ # [visionOS
369
+ old_visionos_deploy_target = config.build_settings["XROS_DEPLOYMENT_TARGET"] ?
370
+ config.build_settings["XROS_DEPLOYMENT_TARGET"] :
371
+ Helpers::Constants.min_visionos_version_supported
372
+ config.build_settings["XROS_DEPLOYMENT_TARGET"] = [Helpers::Constants.min_visionos_version_supported.to_f, old_visionos_deploy_target.to_f].max.to_s
373
+ # visionOS]
374
+ end
375
+ end
376
+ end
377
+
378
+ def self.set_dynamic_frameworks_flags(installer)
379
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
380
+
381
+ # Set "RCT_DYNAMIC_FRAMEWORKS=1" if pod are installed with USE_FRAMEWORKS=dynamic
382
+ # This helps with backward compatibility.
383
+ if pod_name == 'React-RCTFabric' && ENV['USE_FRAMEWORKS'] == 'dynamic'
384
+ Pod::UI.puts "Setting -DRCT_DYNAMIC_FRAMEWORKS=1 to React-RCTFabric".green
385
+ rct_dynamic_framework_flag = " -DRCT_DYNAMIC_FRAMEWORKS=1"
386
+ target_installation_result.native_target.build_configurations.each do |config|
387
+ prev_build_settings = config.build_settings['OTHER_CPLUSPLUSFLAGS'] != nil ? config.build_settings['OTHER_CPLUSPLUSFLAGS'] : "$(inherithed)"
388
+ config.build_settings['OTHER_CPLUSPLUSFLAGS'] = prev_build_settings + rct_dynamic_framework_flag
389
+ end
390
+ end
391
+ end
392
+ end
393
+
394
+ # ========= #
395
+ # Utilities #
396
+ # ========= #
397
+
398
+ def self.extract_projects(installer)
399
+ return installer.aggregate_targets
400
+ .map{ |t| t.user_project }
401
+ .uniq{ |p| p.path }
402
+ .push(installer.pods_project)
403
+ end
404
+
405
+ def self.safe_init(config, setting_name)
406
+ old_config = config.build_settings[setting_name]
407
+ if old_config == nil
408
+ config.build_settings[setting_name] ||= '$(inherited) '
409
+ end
410
+ end
411
+
412
+ def self.add_value_to_setting_if_missing(config, setting_name, value)
413
+ old_config = config.build_settings[setting_name]
414
+ if old_config.is_a?(Array)
415
+ old_config = old_config.join(" ")
416
+ end
417
+
418
+ trimmed_value = value.strip()
419
+ if !old_config.include?(trimmed_value)
420
+ config.build_settings[setting_name] = "#{old_config.strip()} #{trimmed_value}".strip()
421
+ end
422
+ end
423
+
424
+ def self.remove_value_from_setting_if_present(config, setting_name, value)
425
+ old_config = config.build_settings[setting_name]
426
+ if old_config.is_a?(Array)
427
+ old_config = old_config.join(" ")
428
+ end
429
+
430
+ trimmed_value = value.strip()
431
+ if old_config.include?(trimmed_value)
432
+ new_config = old_config.gsub(trimmed_value, "")
433
+ config.build_settings[setting_name] = new_config.strip()
434
+ end
435
+ end
436
+
437
+ def self.is_using_xcode15_0(xcodebuild_manager: Xcodebuild)
438
+ xcodebuild_version = xcodebuild_manager.version
439
+
440
+ if version = self.parse_xcode_version(xcodebuild_version)
441
+ return version["major"] == 15 && version["minor"] == 0
442
+ end
443
+
444
+ return false
445
+ end
446
+
447
+ def self.parse_xcode_version(version_string)
448
+ # The output of xcodebuild -version is something like
449
+ # Xcode 15.0
450
+ # or
451
+ # Xcode 14.3.1
452
+ # We want to capture the version digits
453
+ match = version_string.match(/(\d+)\.(\d+)(?:\.(\d+))?/)
454
+ return nil if match.nil?
455
+
456
+ return {"str" => match[0], "major" => match[1].to_i, "minor" => match[2].to_i};
457
+ end
458
+
459
+ def self.check_minimum_required_xcode(xcodebuild_manager: Xcodebuild)
460
+ version = self.parse_xcode_version(xcodebuild_manager.version)
461
+ if (version.nil? || !Gem::Version::correct?(version["str"]))
462
+ Pod::UI.warn "Unexpected XCode version string '#{xcodebuild_manager.version}'"
463
+ return
464
+ end
465
+
466
+ current = version["str"]
467
+ min_required = Helpers::Constants.min_xcode_version_supported
468
+
469
+ if Gem::Version::new(current) < Gem::Version::new(min_required)
470
+ Pod::UI.puts "React Native requires XCode >= #{min_required}. Found #{current}.".red
471
+ raise "Please upgrade XCode"
472
+ end
473
+ end
474
+
475
+ def self.add_compiler_flag_to_project(installer, flag, configuration: nil)
476
+ projects = self.extract_projects(installer)
477
+
478
+ projects.each do |project|
479
+ project.build_configurations.each do |config|
480
+ self.set_flag_in_config(config, flag, configuration: configuration)
481
+ end
482
+ project.save()
483
+ end
484
+ end
485
+
486
+ def self.remove_compiler_flag_from_project(installer, flag, configuration: nil)
487
+ projects = self.extract_projects(installer)
488
+
489
+ projects.each do |project|
490
+ project.build_configurations.each do |config|
491
+ self.remove_flag_in_config(config, flag, configuration: configuration)
492
+ end
493
+ project.save()
494
+ end
495
+ end
496
+
497
+ def self.add_compiler_flag_to_pods(installer, flag, configuration: nil)
498
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
499
+ target_installation_result.native_target.build_configurations.each do |config|
500
+ self.set_flag_in_config(config, flag, configuration: configuration)
501
+ end
502
+ end
503
+ end
504
+
505
+ def self.set_flag_in_config(config, flag, configuration: nil)
506
+ if configuration == nil || config.name == configuration
507
+ self.add_flag_for_key(config, flag, "OTHER_CFLAGS")
508
+ self.add_flag_for_key(config, flag, "OTHER_CPLUSPLUSFLAGS")
509
+ end
510
+ end
511
+
512
+ def self.remove_flag_in_config(config, flag, configuration: nil)
513
+ if configuration == nil || config.name == configuration
514
+ self.remove_flag_for_key(config, flag, "OTHER_CFLAGS")
515
+ self.remove_flag_for_key(config, flag, "OTHER_CPLUSPLUSFLAGS")
516
+ end
517
+ end
518
+
519
+
520
+ def self.add_flag_for_key(config, flag, key)
521
+ current_setting = config.build_settings[key] ? config.build_settings[key] : "$(inherited)"
522
+
523
+ if current_setting.kind_of?(Array)
524
+ current_setting = current_setting
525
+ .map { |s| s.gsub('"', '') }
526
+ .map { |s| s.gsub('\"', '') }
527
+ .join(" ")
528
+ end
529
+
530
+ if !current_setting.include?(flag)
531
+ current_setting = "#{current_setting} #{flag}"
532
+ end
533
+
534
+ config.build_settings[key] = current_setting
535
+ end
536
+
537
+ def self.remove_flag_for_key(config, flag, key)
538
+ current_setting = config.build_settings[key] ? config.build_settings[key] : "$(inherited)"
539
+
540
+ if current_setting.kind_of?(Array)
541
+ current_setting = current_setting
542
+ .map { |s| s.gsub('"', '') }
543
+ .map { |s| s.gsub('\"', '') }
544
+ .join(" ")
545
+ end
546
+
547
+ if current_setting.include?(flag)
548
+ current_setting.slice! flag
549
+ end
550
+
551
+ config.build_settings[key] = current_setting
552
+ end
553
+
554
+ def self.add_search_path_if_not_included(current_search_paths, new_search_path)
555
+ new_search_path = new_search_path.strip
556
+
557
+ if current_search_paths.is_a?(String)
558
+ current_search_paths = current_search_paths.strip
559
+ return "#{current_search_paths} #{new_search_path}" unless current_search_paths.include?(new_search_path)
560
+ end
561
+
562
+ if current_search_paths.is_a?(Array)
563
+ current_search_paths = current_search_paths.map(&:strip)
564
+ return current_search_paths << new_search_path unless current_search_paths.include?(new_search_path)
565
+ end
566
+
567
+ current_search_paths
568
+ end
569
+
570
+ def self.update_header_paths_if_depends_on(target_installation_result, dependency_name, header_paths)
571
+ depends_on_framework = target_installation_result.native_target.dependencies.any? { |d| d.name == dependency_name }
572
+ if depends_on_framework
573
+ target_installation_result.native_target.build_configurations.each do |config|
574
+ header_search_path = config.build_settings["HEADER_SEARCH_PATHS"] != nil ? config.build_settings["HEADER_SEARCH_PATHS"] : "$(inherited)"
575
+ header_paths.each { |header| header_search_path = ReactNativePodsUtils.add_search_path_if_not_included(header_search_path, header) }
576
+ config.build_settings["HEADER_SEARCH_PATHS"] = header_search_path
577
+ end
578
+ end
579
+ end
580
+
581
+ def self.set_rctfolly_search_paths(target_installation_result)
582
+ ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "RCT-Folly", [
583
+ "\"$(PODS_ROOT)/RCT-Folly\"",
584
+ "\"$(PODS_ROOT)/DoubleConversion\"",
585
+ "\"$(PODS_ROOT)/fast_float/include\"",
586
+ "\"$(PODS_ROOT)/fmt/include\"",
587
+ "\"$(PODS_ROOT)/boost\""
588
+ ])
589
+ end
590
+
591
+ def self.set_codegen_search_paths(target_installation_result)
592
+ header_search_paths = ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "ReactCodegen", "ReactCodegen", [])
593
+ .map { |search_path| "\"#{search_path}\"" }
594
+ ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "ReactCodegen", header_search_paths)
595
+ end
596
+
597
+ def self.set_reactcommon_searchpaths(target_installation_result)
598
+ header_search_paths = ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "ReactCommon", "ReactCommon", ["react/nativemodule/core"])
599
+ .map { |search_path| "\"#{search_path}\"" }
600
+ ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "ReactCommon", header_search_paths)
601
+ end
602
+
603
+ def self.set_rctfabric_search_paths(target_installation_result)
604
+ header_search_paths = ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-RCTFabric", "RCTFabric", [])
605
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-Fabric", "React_Fabric", ["react/renderer/components/view/platform/cxx"]))
606
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-FabricImage", "React_FabricImage", []))
607
+ .concat(ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-Graphics", "React_graphics", ["react/renderer/graphics/platform/ios"]))
608
+ .map { |search_path| "\"#{search_path}\"" }
609
+
610
+ ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-RCTFabric", header_search_paths)
611
+ end
612
+
613
+ def self.set_imagemanager_search_path(target_installation_result)
614
+ header_search_paths = ReactNativePodsUtils.create_header_search_path_for_frameworks("PODS_CONFIGURATION_BUILD_DIR", "React-Fabric", "React_Fabric", ["react/renderer/imagemanager/platform/ios"])
615
+ .map { |search_path| "\"#{search_path}\"" }
616
+ ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths)
617
+ end
618
+
619
+ def self.react_native_pods
620
+ return [
621
+ "DoubleConversion",
622
+ "FBLazyVector",
623
+ "RCT-Folly",
624
+ "RCTRequired",
625
+ "RCTTypeSafety",
626
+ "React",
627
+ "ReactCodegen",
628
+ "React-Core",
629
+ "React-CoreModules",
630
+ "React-Fabric",
631
+ "React-FabricImage",
632
+ "React-ImageManager",
633
+ "React-RCTActionSheet",
634
+ "React-RCTAnimation",
635
+ "React-RCTAppDelegate",
636
+ "React-RCTBlob",
637
+ "React-RCTFabric",
638
+ "React-RCTImage",
639
+ "React-RCTLinking",
640
+ "React-RCTNetwork",
641
+ "React-RCTPushNotification",
642
+ "React-RCTSettings",
643
+ "React-RCTText",
644
+ "React-RCTTest",
645
+ "React-RCTVibration",
646
+ "React-callinvoker",
647
+ "React-cxxreact",
648
+ "React-graphics",
649
+ "React-jsc",
650
+ "React-jsi",
651
+ "React-jsiexecutor",
652
+ "React-jsinspector",
653
+ "React-logger",
654
+ "React-perflogger",
655
+ "React-rncore",
656
+ "React-runtimeexecutor",
657
+ "React-timing",
658
+ "ReactCommon",
659
+ "Yoga",
660
+ "boost",
661
+ "fast_float",
662
+ "fmt",
663
+ "glog",
664
+ "hermes-engine",
665
+ "React-hermes",
666
+ ]
667
+ end
668
+
669
+ def self.add_search_path_to_result(result, base_path, additional_paths, include_base_path)
670
+ if (include_base_path)
671
+ result << base_path
672
+ end
673
+
674
+ additional_paths.each { |extra_path|
675
+ result << File.join(base_path, extra_path)
676
+ }
677
+ return result
678
+ end
679
+
680
+ def self.add_ndebug_flag_to_pods_in_release(installer)
681
+ ndebug_flag = " -DNDEBUG"
682
+
683
+ installer.aggregate_targets.each do |aggregate_target|
684
+ aggregate_target.xcconfigs.each do |config_name, config_file|
685
+ is_release = config_name.downcase.include?("release") || config_name.downcase.include?("production")
686
+ unless is_release
687
+ next
688
+ end
689
+ self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CPLUSPLUSFLAGS', ndebug_flag);
690
+ self.add_flag_to_map_with_inheritance(config_file.attributes, 'OTHER_CFLAGS', ndebug_flag);
691
+
692
+ xcconfig_path = aggregate_target.xcconfig_path(config_name)
693
+ config_file.save_as(xcconfig_path)
694
+ end
695
+ end
696
+
697
+ installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
698
+ target_installation_result.native_target.build_configurations.each do |config|
699
+ is_release = config.name.downcase.include?("release") || config.name.downcase.include?("production")
700
+ unless is_release
701
+ next
702
+ end
703
+ self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CPLUSPLUSFLAGS', ndebug_flag);
704
+ self.add_flag_to_map_with_inheritance(config.build_settings, 'OTHER_CFLAGS', ndebug_flag);
705
+ end
706
+ end
707
+ end
708
+
709
+ def self.add_flag_to_map_with_inheritance(map, field, flag)
710
+ if map[field] == nil
711
+ map[field] = "$(inherited)" + flag
712
+ else
713
+ unless map[field].include?(flag)
714
+ if map[field].instance_of? String
715
+ map[field] = map[field] + flag
716
+ elsif map[field].instance_of? Array
717
+ map[field].push(flag)
718
+ end
719
+ end
720
+ unless map[field].include?("$(inherited)")
721
+ if map[field].instance_of? String
722
+ map[field] = "$(inherited) " + map[field]
723
+ elsif map[field].instance_of? Array
724
+ map[field].unshift("$(inherited)")
725
+ end
726
+ end
727
+ end
728
+ end
729
+ end