react-native-macos 0.78.4 → 0.78.5

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