react-native-beidou 1.0.2 → 1.0.4

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 (71) hide show
  1. package/BeiDouAIDLTestPage.tsx +710 -0
  2. package/Compass.android.tsx +20 -0
  3. package/TestPage.ts +6 -0
  4. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  8. package/android/.idea/AndroidProjectSystem.xml +6 -0
  9. package/android/.idea/gradle.xml +13 -0
  10. package/android/.idea/migrations.xml +10 -0
  11. package/android/.idea/misc.xml +9 -0
  12. package/android/.idea/runConfigurations.xml +17 -0
  13. package/android/.idea/vcs.xml +6 -0
  14. package/android/build.gradle +3 -0
  15. package/android/src/main/AndroidManifest.xml +7 -0
  16. package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothModule.java +343 -101
  17. package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothPackage.java +4 -1
  18. package/android/src/main/java/com/cmcc_rn_module/ChatDBManager.java +306 -0
  19. package/android/src/main/java/com/cmcc_rn_module/JsonUtil.java +113 -7
  20. package/android/src/main/java/com/cmcc_rn_module/view/CompassManager.java +41 -0
  21. package/android/src/main/java/com/cmcc_rn_module/view/CompassView.java +277 -0
  22. package/android/src/main/libs/bluetooth-sdk.aar +0 -0
  23. package/index.ts +188 -10
  24. package/ios/BDTCompassViewManager.h +15 -0
  25. package/ios/BDTCompassViewManager.m +24 -0
  26. package/ios/BeiDouBluetoothModule.h +20 -0
  27. package/ios/BeiDouBluetoothModule.m +424 -0
  28. package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
  29. package/ios/BeidouBluetooth.framework/Headers/BDTBluetoothManager.h +76 -0
  30. package/ios/BeidouBluetooth.framework/Headers/BDTChatDBManager.h +41 -0
  31. package/ios/BeidouBluetooth.framework/Headers/BDTDataPacketBuilder.h +62 -0
  32. package/ios/BeidouBluetooth.framework/Headers/BeidouBluetooth.h +21 -0
  33. package/ios/BeidouBluetooth.framework/Info.plist +0 -0
  34. package/ios/BeidouBluetooth.framework/Modules/module.modulemap +6 -0
  35. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
  36. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements +0 -0
  37. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
  38. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +177 -0
  39. package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
  40. package/ios/CompassView.h +20 -0
  41. package/ios/CompassView.m +201 -0
  42. package/package.json +5 -2
  43. package/android/.gradle/8.8/checksums/checksums.lock +0 -0
  44. package/android/.gradle/8.8/dependencies-accessors/gc.properties +0 -0
  45. package/android/.gradle/8.8/fileChanges/last-build.bin +0 -0
  46. package/android/.gradle/8.8/fileHashes/fileHashes.bin +0 -0
  47. package/android/.gradle/8.8/fileHashes/fileHashes.lock +0 -0
  48. package/android/.gradle/8.8/gc.properties +0 -0
  49. package/ios/Podfile +0 -79
  50. package/ios/build_sdk.sh +0 -30
  51. package/ios/cmcc_rn_module/AppDelegate.h +0 -8
  52. package/ios/cmcc_rn_module/AppDelegate.mm +0 -108
  53. package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.h +0 -17
  54. package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.m +0 -38
  55. package/ios/cmcc_rn_module/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  56. package/ios/cmcc_rn_module/Images.xcassets/Contents.json +0 -6
  57. package/ios/cmcc_rn_module/Info.plist +0 -62
  58. package/ios/cmcc_rn_module/LaunchScreen.storyboard +0 -47
  59. package/ios/cmcc_rn_module/main.m +0 -10
  60. package/ios/cmcc_rn_module.xcodeproj/project.pbxproj +0 -708
  61. package/ios/cmcc_rn_module.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  62. package/ios/cmcc_rn_module.xcodeproj/xcshareddata/xcschemes/cmcc_rn_module.xcscheme +0 -88
  63. package/ios/cmcc_rn_module.xcworkspace/contents.xcworkspacedata +0 -10
  64. package/ios/cmcc_rn_module.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  65. package/ios/cmcc_rn_moduleTests/Info.plist +0 -24
  66. package/ios/cmcc_rn_moduleTests/cmcc_rn_moduleTests.m +0 -66
  67. package/ios/reset_env.sh +0 -24
  68. package/ios/scripts/RNReanimated.podspec +0 -90
  69. package/ios/scripts/generate_dynamic_pod.rb +0 -166
  70. package/ios/scripts/native_modules_dy.rb +0 -317
  71. package/ios/scripts/react_native_pods_dy.rb +0 -773
@@ -1,773 +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 'pathname'
7
- require_relative './react_native_pods_utils/script_phases.rb'
8
-
9
- $CODEGEN_OUTPUT_DIR = 'build/generated/ios'
10
- $CODEGEN_COMPONENT_DIR = 'react/renderer/components'
11
- $CODEGEN_MODULE_DIR = '.'
12
- $REACT_CODEGEN_PODSPEC_GENERATED = false
13
- $REACT_CODEGEN_DISCOVERY_DONE = false
14
- DEFAULT_OTHER_CPLUSPLUSFLAGS = '$(inherited)'
15
- NEW_ARCH_OTHER_CPLUSPLUSFLAGS = '$(inherited) -DRCT_NEW_ARCH_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
16
-
17
- def use_react_native! (options={})
18
- # The prefix to react-native
19
- prefix = options[:path] ||= "../node_modules/react-native"
20
-
21
- # Include Fabric dependencies
22
- fabric_enabled = options[:fabric_enabled] ||= false
23
-
24
- # Include DevSupport dependency
25
- production = options[:production] ||= false
26
-
27
- # Include Hermes dependencies
28
- hermes_enabled = options[:hermes_enabled] ||= false
29
-
30
- # Codegen Discovery is required when enabling new architecture.
31
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
32
- Pod::UI.puts 'Setting USE_CODEGEN_DISCOVERY=1'
33
- ENV['USE_CODEGEN_DISCOVERY'] = '1'
34
- end
35
-
36
- if `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i == 1 && !RUBY_PLATFORM.include?('arm64')
37
- Pod::UI.warn 'Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).'
38
- Pod::UI.warn ' - Emulated x86_64 is slower than native arm64'
39
- Pod::UI.warn ' - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)'
40
- Pod::UI.warn 'Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.'
41
- end
42
-
43
- # The Pods which should be included in all projects
44
- generate_dynamic_pod(:pod_name => 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector")
45
- generate_dynamic_pod(:pod_name => 'FBReactNativeSpec', :path => "#{prefix}/React/FBReactNativeSpec")
46
- generate_dynamic_pod(:pod_name => 'RCTRequired', :path => "#{prefix}/Libraries/RCTRequired")
47
- generate_dynamic_pod(:pod_name => 'RCTTypeSafety', :path => "#{prefix}/Libraries/TypeSafety")
48
- generate_dynamic_pod(:pod_name => 'React', :path => "#{prefix}/")
49
- generate_dynamic_pod(:pod_name => 'React-Core', :path => "#{prefix}/")
50
- generate_dynamic_pod(:pod_name => 'React-CoreModules', :path => "#{prefix}/React/CoreModules")
51
- generate_dynamic_pod(:pod_name => 'React-RCTActionSheet', :path => "#{prefix}/Libraries/ActionSheetIOS")
52
- generate_dynamic_pod(:pod_name => 'React-RCTAnimation', :path => "#{prefix}/Libraries/NativeAnimation")
53
- generate_dynamic_pod(:pod_name => 'React-RCTBlob', :path => "#{prefix}/Libraries/Blob")
54
- generate_dynamic_pod(:pod_name => 'React-RCTImage', :path => "#{prefix}/Libraries/Image")
55
- generate_dynamic_pod(:pod_name => 'React-RCTLinking', :path => "#{prefix}/Libraries/LinkingIOS")
56
- generate_dynamic_pod(:pod_name => 'React-RCTNetwork', :path => "#{prefix}/Libraries/Network")
57
- generate_dynamic_pod(:pod_name => 'React-RCTSettings', :path => "#{prefix}/Libraries/Settings")
58
- generate_dynamic_pod(:pod_name => 'React-RCTText', :path => "#{prefix}/Libraries/Text")
59
- generate_dynamic_pod(:pod_name => 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration")
60
- generate_dynamic_pod(:pod_name => 'React-Core/RCTWebSocket', :path => "#{prefix}/")
61
-
62
- unless production
63
- generate_dynamic_pod(:pod_name => 'React-Core/DevSupport', :path => "#{prefix}/")
64
- end
65
-
66
- generate_dynamic_pod(:pod_name => 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact")
67
- generate_dynamic_pod(:pod_name => 'React-jsi', :path => "#{prefix}/ReactCommon/jsi")
68
- generate_dynamic_pod(:pod_name => 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor")
69
- generate_dynamic_pod(:pod_name => 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector")
70
- generate_dynamic_pod(:pod_name => 'React-callinvoker', :path => "#{prefix}/ReactCommon/callinvoker")
71
- generate_dynamic_pod(:pod_name => 'React-runtimeexecutor', :path => "#{prefix}/ReactCommon/runtimeexecutor")
72
- generate_dynamic_pod(:pod_name => 'React-perflogger', :path => "#{prefix}/ReactCommon/reactperflogger")
73
- generate_dynamic_pod(:pod_name => 'React-logger', :path => "#{prefix}/ReactCommon/logger")
74
- generate_dynamic_pod(:pod_name => 'ReactCommon/turbomodule/core', :path => "#{prefix}/ReactCommon")
75
- generate_dynamic_pod(:pod_name => 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true)
76
-
77
- generate_dynamic_pod(:pod_name => 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec")
78
- generate_dynamic_pod(:pod_name => 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec")
79
- generate_dynamic_pod(:pod_name => 'boost', :podspec => "#{prefix}/third-party-podspecs/boost.podspec")
80
- generate_dynamic_pod(:pod_name => 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec")
81
-
82
- if ENV['USE_CODEGEN_DISCOVERY'] == '1'
83
- app_path = options[:app_path]
84
- config_file_dir = options[:config_file_dir]
85
- use_react_native_codegen_discovery!({
86
- react_native_path: prefix,
87
- app_path: app_path,
88
- fabric_enabled: fabric_enabled,
89
- config_file_dir: config_file_dir,
90
- })
91
- else
92
- # Generate a podspec file for generated files.
93
- # This gets generated in use_react_native_codegen_discovery when codegen discovery is enabled.
94
- react_codegen_spec = get_react_codegen_spec(fabric_enabled: fabric_enabled)
95
- generate_react_codegen_podspec!(react_codegen_spec)
96
- end
97
-
98
- generate_dynamic_pod(:pod_name => 'React-Codegen', :path => $CODEGEN_OUTPUT_DIR)
99
-
100
- if fabric_enabled
101
- checkAndGenerateEmptyThirdPartyProvider!(prefix)
102
- generate_dynamic_pod(:pod_name => 'React-Fabric', :path => "#{prefix}/ReactCommon")
103
- generate_dynamic_pod(:pod_name => 'React-rncore', :path => "#{prefix}/ReactCommon")
104
- generate_dynamic_pod(:pod_name => 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics")
105
- generate_dynamic_pod(:pod_name => 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi")
106
- generate_dynamic_pod(:pod_name => 'React-RCTFabric', :path => "#{prefix}/React")
107
- generate_dynamic_pod(:pod_name => 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec")
108
- end
109
-
110
- if hermes_enabled
111
- generate_dynamic_pod(:pod_name => 'React-hermes', :path => "#{prefix}/ReactCommon/hermes")
112
- generate_dynamic_pod(:pod_name => 'hermes-engine', :version => '~> 0.11.0')
113
- generate_dynamic_pod(:pod_name => 'libevent', :version => '~> 2.1.12')
114
- end
115
- end
116
-
117
- def generate_dynamic_pod(options = {})
118
- output_file = "rn_dynamic_pod.rb"
119
- # 转为字符串
120
- pod_content = ""
121
-
122
- if options[:configurations].present?
123
- pod_content = ", :configurations => #{options[:configurations]}"
124
- end
125
-
126
- if options[:modular_headers]
127
- pod_content = "#{pod_content}, :modular_headers => #{options[:modular_headers]}"
128
- end
129
-
130
- if options[:path].present?
131
- pod options[:pod_name], :path => options[:path], :modular_headers => options[:modular_headers], :configurations => options[:configurations]
132
- elsif options[:podspec].present?
133
- pod options[:pod_name], :podspec => options[:podspec], :modular_headers => options[:modular_headers], :configurations => options[:configurations]
134
- elsif options[:version].present?
135
- pod options[:pod_name], options[:version], :modular_headers => options[:modular_headers], :configurations => options[:configurations]
136
- end
137
-
138
-
139
- # 未开启 || Pod Path为空 直接退出该流程
140
- if ENV['DYNAMIC_POD_ENABLED'].nil? || ENV['DYNAMIC_POD_ENABLED'] != "true" || ENV['RN_POD_GIT_PATH'].nil? || ENV['RN_POD_GIT_PATH'].empty?
141
- return
142
- end
143
-
144
- # 将../node_modules替换为环境变量路径
145
- pod_content = replace_pod_path!(options, pod_content)
146
-
147
- if pod_content.empty?
148
- return
149
- end
150
-
151
- # 生成dynamic podfile
152
- output_dynamic_pod(output_file, pod_content)
153
-
154
- end
155
-
156
- # 将../node_modules替换为环境变量路径
157
- def replace_pod_path!(options, pod_content)
158
-
159
- rn_pod_git_path = ENV['RN_POD_GIT_PATH']
160
-
161
- if rn_pod_git_path.present?
162
- if options[:path].present?
163
-
164
- if rn_pod_git_path.to_s.start_with?('http://')
165
- pod_content = " pod '#{options[:pod_name]}', :git => '#{rn_pod_git_path}.git', :tag => '0.68.7.1'#{pod_content}\n"
166
- else
167
- pod_content = " pod '#{options[:pod_name]}', :path => '#{rn_pod_git_path}'#{pod_content.present? ? "#{pod_content}" : ""}\n"
168
- end
169
- elsif options[:podspec].present?
170
- if options[:pod_name] == "glog"
171
- glog_git_path = Pathname.new(rn_pod_git_path).dirname
172
- if glog_git_path.to_s.start_with?('http://')
173
- pod_content = " pod '#{options[:pod_name]}', :git => '#{glog_git_path}/#{options[:pod_name]}.git', :tag => '0.3.5'#{pod_content}\n"
174
- else
175
- pod_content = " pod '#{options[:pod_name]}', :path => '#{glog_git_path}/#{options[:pod_name]}'#{pod_content.present? ? "#{pod_content}" : ""}\n"
176
- end
177
- elsif
178
- replace_podspec_path = options[:podspec].sub('../node_modules/react-native', $dynamic_pod_pre_dir)
179
- pod_content = " pod '#{options[:pod_name]}', :podspec => '#{replace_podspec_path}'#{pod_content}\n"
180
- copy_pod_to_project(options[:podspec], replace_podspec_path)
181
- end
182
- elsif options[:version].present?
183
- pod_content = " pod '#{options[:pod_name]}', '#{options[:version]}'#{pod_content}\n"
184
- end
185
- end
186
-
187
- pod_content
188
- end
189
-
190
- # 将pod库拷贝到工程目录下
191
- def copy_pod_to_project(source_file, traget_file)
192
-
193
- # 未开启 || Pod Path为空 直接退出该流程
194
- if ENV['DYNAMIC_POD_ENABLED'].nil? || ENV['DYNAMIC_POD_ENABLED'] != "true" || ENV['DYNAMIC_POD_PATH'].nil? || ENV['DYNAMIC_POD_PATH'].empty?
195
- return
196
- end
197
-
198
- dir_items = ENV['DYNAMIC_POD_PATH'].split(',')
199
-
200
- dir_items.each do |item|
201
- if File.exist?(item)
202
- # 拼接目录
203
- des_file = File.join(item, traget_file)
204
-
205
- dir_path = Pathname.new(des_file).dirname
206
- # 目录不存在创建
207
- unless Dir.exist?(dir_path)
208
- FileUtils.mkdir_p(dir_path)
209
- end
210
-
211
- begin
212
- # 删除已存在podsepc
213
- # FileUtils.rm(des_file)
214
- # 拷贝新内容
215
- FileUtils.cp(source_file, des_file)
216
- puts "\033[32mCopying #{source_file} >> #{des_file}\033[0m"
217
- rescue StandardError => e
218
- puts "\033[33m[可忽略] Copying fail #{source_file} >> #{des_file}\033[0m"
219
- end
220
-
221
- else
222
- puts "\033[33m[可忽略][#{item}] 工程目录不存在\033[0m"
223
- end
224
- end
225
- end
226
-
227
- def get_default_flags()
228
- flags = {
229
- :fabric_enabled => false,
230
- :hermes_enabled => false,
231
- }
232
-
233
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
234
- flags[:fabric_enabled] = true
235
- flags[:hermes_enabled] = true
236
- end
237
-
238
- return flags
239
- end
240
-
241
- def use_flipper!(versions = {}, configurations: ['Debug'])
242
- versions['Flipper'] ||= '0.125.0'
243
- versions['Flipper-Boost-iOSX'] ||= '1.76.0.1.11'
244
- versions['Flipper-DoubleConversion'] ||= '3.2.0'
245
- versions['Flipper-Fmt'] ||= '7.1.7'
246
- versions['Flipper-Folly'] ||= '2.6.10'
247
- versions['Flipper-Glog'] ||= '0.5.0.4'
248
- versions['Flipper-PeerTalk'] ||= '0.0.4'
249
- versions['Flipper-RSocket'] ||= '1.4.3'
250
- versions['OpenSSL-Universal'] ||= '1.1.1100'
251
- generate_dynamic_pod(:pod_name => 'FlipperKit', :version => versions['Flipper'], :configurations => configurations)
252
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitLayoutPlugin', :version => versions['Flipper'], :configurations => configurations)
253
- generate_dynamic_pod(:pod_name => 'FlipperKit/SKIOSNetworkPlugin', :version => versions['Flipper'], :configurations => configurations)
254
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitUserDefaultsPlugin', :version => versions['Flipper'], :configurations => configurations)
255
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitReactPlugin', :version => versions['Flipper'], :configurations => configurations)
256
- # List all transitive dependencies for FlipperKit pods
257
- # to avoid them being linked in Release builds
258
- generate_dynamic_pod(:pod_name => 'Flipper', :version => versions['Flipper'], :configurations => configurations)
259
- generate_dynamic_pod(:pod_name => 'Flipper-Boost-iOSX', :version => versions['Flipper-Boost-iOSX'], :configurations => configurations)
260
- generate_dynamic_pod(:pod_name => 'Flipper-DoubleConversion', :version => versions['Flipper-DoubleConversion'], :configurations => configurations)
261
- generate_dynamic_pod(:pod_name => 'Flipper-Fmt', :version => versions['Flipper-Fmt'], :configurations => configurations)
262
- generate_dynamic_pod(:pod_name => 'Flipper-Folly', :version => versions['Flipper-Folly'], :configurations => configurations)
263
- generate_dynamic_pod(:pod_name => 'Flipper-Glog', :version => versions['Flipper-Glog'], :configurations => configurations)
264
- generate_dynamic_pod(:pod_name => 'Flipper-PeerTalk', :version => versions['Flipper-PeerTalk'], :configurations => configurations)
265
- generate_dynamic_pod(:pod_name => 'Flipper-RSocket', :version => versions['Flipper-RSocket'], :configurations => configurations)
266
- generate_dynamic_pod(:pod_name => 'FlipperKit/Core', :version => versions['Flipper'], :configurations => configurations)
267
- generate_dynamic_pod(:pod_name => 'FlipperKit/CppBridge', :version => versions['Flipper'], :configurations => configurations)
268
- generate_dynamic_pod(:pod_name => 'FlipperKit/FBCxxFollyDynamicConvert', :version => versions['Flipper'], :configurations => configurations)
269
- generate_dynamic_pod(:pod_name => 'FlipperKit/FBDefines', :version => versions['Flipper'], :configurations => configurations)
270
- generate_dynamic_pod(:pod_name => 'FlipperKit/FKPortForwarding', :version => versions['Flipper'], :configurations => configurations)
271
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitHighlightOverlay', :version => versions['Flipper'], :configurations => configurations)
272
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitLayoutTextSearchable', :version => versions['Flipper'], :configurations => configurations)
273
- generate_dynamic_pod(:pod_name => 'FlipperKit/FlipperKitNetworkPlugin', :version => versions['Flipper'], :configurations => configurations)
274
- generate_dynamic_pod(:pod_name => 'OpenSSL-Universal', :version => versions['OpenSSL-Universal'], :configurations => configurations)
275
- end
276
-
277
- def has_pod(installer, name)
278
- installer.pods_project.pod_group(name) != nil
279
- end
280
-
281
- # Post Install processing for Flipper
282
- def flipper_post_install(installer)
283
- installer.pods_project.targets.each do |target|
284
- if target.name == 'YogaKit'
285
- target.build_configurations.each do |config|
286
- config.build_settings['SWIFT_VERSION'] = '4.1'
287
- end
288
- end
289
-
290
- # Enable flipper for React-Core Debug configuration
291
- if target.name == 'React-Core'
292
- target.build_configurations.each do |config|
293
- if config.name == 'Debug'
294
- config.build_settings['OTHER_CFLAGS'] = "$(inherited) -DFB_SONARKIT_ENABLED=1"
295
- end
296
- end
297
- end
298
- end
299
- end
300
-
301
- def exclude_architectures(installer)
302
- projects = installer.aggregate_targets
303
- .map{ |t| t.user_project }
304
- .uniq{ |p| p.path }
305
- .push(installer.pods_project)
306
-
307
- # Hermes does not support `i386` architecture
308
- excluded_archs_default = has_pod(installer, 'hermes-engine') ? "i386" : ""
309
-
310
- projects.each do |project|
311
- project.build_configurations.each do |config|
312
- config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default
313
- end
314
-
315
- project.save()
316
- end
317
- end
318
-
319
- def fix_library_search_paths(installer)
320
- def fix_config(config)
321
- lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
322
- if lib_search_paths
323
- 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)\"")
324
- # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
325
- # since the libraries there are only built for x86_64 and i386.
326
- lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
327
- lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
328
- if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
329
- # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
330
- lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
331
- end
332
- end
333
- end
334
- end
335
-
336
- projects = installer.aggregate_targets
337
- .map{ |t| t.user_project }
338
- .uniq{ |p| p.path }
339
- .push(installer.pods_project)
340
-
341
- projects.each do |project|
342
- project.build_configurations.each do |config|
343
- fix_config(config)
344
- end
345
- project.native_targets.each do |target|
346
- target.build_configurations.each do |config|
347
- fix_config(config)
348
- end
349
- end
350
- project.save()
351
- end
352
- end
353
-
354
- def react_native_post_install(installer)
355
- if has_pod(installer, 'Flipper')
356
- flipper_post_install(installer)
357
- end
358
-
359
- exclude_architectures(installer)
360
- fix_library_search_paths(installer)
361
-
362
- cpp_flags = DEFAULT_OTHER_CPLUSPLUSFLAGS
363
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
364
- cpp_flags = NEW_ARCH_OTHER_CPLUSPLUSFLAGS
365
- end
366
- modify_flags_for_new_architecture(installer, cpp_flags)
367
-
368
- end
369
-
370
- def modify_flags_for_new_architecture(installer, cpp_flags)
371
- # Add RCT_NEW_ARCH_ENABLED to Target pods xcconfig
372
- installer.aggregate_targets.each do |aggregate_target|
373
- aggregate_target.xcconfigs.each do |config_name, config_file|
374
- config_file.attributes['OTHER_CPLUSPLUSFLAGS'] = cpp_flags
375
- xcconfig_path = aggregate_target.xcconfig_path(config_name)
376
- Pod::UI.puts xcconfig_path
377
- config_file.save_as(xcconfig_path)
378
- end
379
- end
380
- # Add RCT_NEW_ARCH_ENABLED to Pods project xcconfig
381
- installer.pods_project.targets.each do |target|
382
- # if target.name == 'React-Core'
383
- if target.name == 'React-Core'
384
- puts "#{target.name}"
385
- target.build_configurations.each do |config|
386
- config.build_settings['OTHER_CPLUSPLUSFLAGS'] = cpp_flags
387
- end
388
- end
389
- end
390
- end
391
-
392
- def build_codegen!(react_native_path)
393
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
394
- codegen_repo_path = "#{relative_installation_root}/#{react_native_path}/packages/react-native-codegen";
395
- codegen_npm_path = "#{relative_installation_root}/#{react_native_path}/../react-native-codegen";
396
- codegen_cli_path = ""
397
- if Dir.exist?(codegen_repo_path)
398
- codegen_cli_path = codegen_repo_path
399
- elsif Dir.exist?(codegen_npm_path)
400
- codegen_cli_path = codegen_npm_path
401
- else
402
- raise "[codegen] Couldn't not find react-native-codegen."
403
- end
404
-
405
- if !Dir.exist?("#{codegen_cli_path}/lib")
406
- Pod::UI.puts "[Codegen] building #{codegen_cli_path}."
407
- system("#{codegen_cli_path}/scripts/oss/build.sh")
408
- end
409
- end
410
-
411
- # This is a temporary supporting function until we enable use_react_native_codegen_discovery by default.
412
- def checkAndGenerateEmptyThirdPartyProvider!(react_native_path)
413
- return if ENV['USE_CODEGEN_DISCOVERY'] == '1'
414
-
415
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
416
- output_dir = "#{relative_installation_root}/#{$CODEGEN_OUTPUT_DIR}"
417
-
418
- provider_h_path = "#{output_dir}/RCTThirdPartyFabricComponentsProvider.h"
419
- provider_cpp_path ="#{output_dir}/RCTThirdPartyFabricComponentsProvider.cpp"
420
-
421
- if(!File.exist?(provider_h_path) || !File.exist?(provider_cpp_path))
422
- # build codegen
423
- build_codegen!(react_native_path)
424
-
425
- # Just use a temp empty schema list.
426
- temp_schema_list_path = "#{output_dir}/tmpSchemaList.txt"
427
- File.open(temp_schema_list_path, 'w') do |f|
428
- f.write('[]')
429
- f.fsync
430
- end
431
-
432
- Pod::UI.puts '[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider'
433
- Pod::Executable.execute_command(
434
- 'node',
435
- [
436
- "#{relative_installation_root}/#{react_native_path}/scripts/generate-provider-cli.js",
437
- "--platform", 'ios',
438
- "--schemaListPath", temp_schema_list_path,
439
- "--outputDir", "#{output_dir}"
440
- ])
441
- File.delete(temp_schema_list_path) if File.exist?(temp_schema_list_path)
442
- end
443
- end
444
-
445
- def get_react_codegen_spec(options={})
446
- fabric_enabled = options[:fabric_enabled] ||= false
447
- script_phases = options[:script_phases] ||= nil
448
-
449
- package = JSON.parse(File.read(File.join(__dir__, "..", "package.json")))
450
- version = package['version']
451
-
452
- source = { :git => 'https://github.com/facebook/react-native.git' }
453
- if version == '1000.0.0'
454
- # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
455
- source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
456
- else
457
- source[:tag] = "v#{version}"
458
- end
459
-
460
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
461
- folly_version = '2021.06.28.00-v2'
462
- boost_version = '1.76.0'
463
- boost_compiler_flags = '-Wno-documentation'
464
-
465
- spec = {
466
- 'name' => "React-Codegen",
467
- 'version' => version,
468
- 'summary' => 'Temp pod for generated files for React Native',
469
- 'homepage' => 'https://facebook.com/',
470
- 'license' => 'Unlicense',
471
- 'authors' => 'Facebook',
472
- 'compiler_flags' => "#{folly_compiler_flags} #{boost_compiler_flags} -Wno-nullability-completeness",
473
- 'source' => { :git => '' },
474
- 'header_mappings_dir' => './',
475
- 'platforms' => {
476
- 'ios' => '11.0',
477
- },
478
- 'source_files' => "**/*.{h,mm,cpp}",
479
- 'pod_target_xcconfig' => { "HEADER_SEARCH_PATHS" =>
480
- [
481
- "\"$(PODS_ROOT)/boost\"",
482
- "\"$(PODS_ROOT)/RCT-Folly\"",
483
- "\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
484
- "\"$(PODS_ROOT)/Headers/Private/React-Fabric\"",
485
- "\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
486
- ].join(' ')
487
- },
488
- 'dependencies': {
489
- "FBReactNativeSpec": [version],
490
- "React-jsiexecutor": [version],
491
- "RCT-Folly": [folly_version],
492
- "RCTRequired": [version],
493
- "RCTTypeSafety": [version],
494
- "React-Core": [version],
495
- "React-jsi": [version],
496
- "ReactCommon/turbomodule/core": [version]
497
- }
498
- }
499
-
500
- if fabric_enabled
501
- spec[:'dependencies'].merge!({
502
- 'React-graphics': [version],
503
- 'React-rncore': [version],
504
- });
505
- end
506
-
507
- if script_phases
508
- Pod::UI.puts "[Codegen] Adding script_phases to React-Codegen."
509
- spec[:'script_phases'] = script_phases
510
- end
511
-
512
- return spec
513
- end
514
-
515
- def get_codegen_config_from_file(config_path, config_key)
516
- empty = {'libraries' => []}
517
- if !File.exist?(config_path)
518
- return empty
519
- end
520
-
521
- config = JSON.parse(File.read(config_path))
522
- return config[config_key] ? config[config_key] : empty
523
- end
524
-
525
- def get_react_codegen_script_phases(options={})
526
- app_path = options[:app_path] ||= ''
527
- if !app_path
528
- Pod::UI.warn '[Codegen] error: app_path is requried to use codegen discovery.'
529
- exit 1
530
- end
531
-
532
- # We need to convert paths to relative path from installation_root for the script phase for CI.
533
- relative_app_root = Pathname.new(app_path).relative_path_from(Pod::Config.instance.installation_root)
534
-
535
- config_file_dir = options[:config_file_dir] ||= ''
536
- relative_config_file_dir = ''
537
- if config_file_dir != ''
538
- relative_config_file_dir = Pathname.new(config_file_dir).relative_path_from(Pod::Config.instance.installation_root)
539
- end
540
-
541
- fabric_enabled = options[:fabric_enabled] ||= false
542
-
543
- # react_native_path should be relative already.
544
- react_native_path = options[:react_native_path] ||= "../node_modules/react-native"
545
-
546
- # Generate input files for in-app libaraies which will be used to check if the script needs to be run.
547
- # TODO: Ideally, we generate the input_files list from generate-artifacts.js and read the result here.
548
- # Or, generate this podspec in generate-artifacts.js as well.
549
- config_key = options[:config_key] ||= 'codegenConfig'
550
- app_package_path = File.join(app_path, 'package.json')
551
- app_codegen_config = get_codegen_config_from_file(app_package_path, config_key)
552
- file_list = []
553
- app_codegen_config['libraries'].each do |library|
554
- library_dir = File.join(app_path, library['jsSrcsDir'])
555
- file_list.concat (`find #{library_dir} -type f \\( -name "Native*.js" -or -name "*NativeComponent.js" \\)`.split("\n").sort)
556
- end
557
- input_files = file_list.map { |filename| "${PODS_ROOT}/../#{Pathname.new(filename).relative_path_from(Pod::Config.instance.installation_root)}" }
558
-
559
- # Add a script phase to trigger generate artifact.
560
- # Some code is duplicated so that it's easier to delete the old way and switch over to this once it's stabilized.
561
- return {
562
- 'name': 'Generate Specs',
563
- 'execution_position': :before_compile,
564
- 'input_files' => input_files,
565
- 'show_env_vars_in_log': true,
566
- 'output_files': ["${DERIVED_FILE_DIR}/react-codegen.log"],
567
- 'script': get_script_phases_with_codegen_discovery(
568
- react_native_path: react_native_path,
569
- relative_app_root: relative_app_root,
570
- relative_config_file_dir: relative_config_file_dir,
571
- fabric_enabled: fabric_enabled
572
- ),
573
- }
574
-
575
- end
576
-
577
- def set_react_codegen_podspec_generated(value)
578
- $REACT_CODEGEN_PODSPEC_GENERATED = value
579
- end
580
-
581
- def has_react_codegen_podspec_generated()
582
- return $REACT_CODEGEN_PODSPEC_GENERATED
583
- end
584
-
585
- def generate_react_codegen_podspec!(spec)
586
- # This podspec file should only be create once in the session/pod install.
587
- # This happens when multiple targets are calling use_react_native!.
588
- if has_react_codegen_podspec_generated()
589
- Pod::UI.puts "[Codegen] Skipping React-Codegen podspec generation."
590
- return
591
- end
592
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
593
- output_dir = "#{relative_installation_root}/#{$CODEGEN_OUTPUT_DIR}"
594
- Pod::Executable.execute_command("mkdir", ["-p", output_dir]);
595
-
596
- podspec_path = File.join(output_dir, 'React-Codegen.podspec.json')
597
- Pod::UI.puts "[Codegen] Generating #{podspec_path}"
598
-
599
- File.open(podspec_path, 'w') do |f|
600
- f.write(spec.to_json)
601
- f.fsync
602
- end
603
-
604
- set_react_codegen_podspec_generated(true)
605
-
606
- return {
607
- "spec" => spec,
608
- "path" => $CODEGEN_OUTPUT_DIR, # Path needs to be relative to `Podfile`
609
- }
610
- end
611
-
612
-
613
- def use_react_native_codegen_discovery!(options={})
614
- return if ENV['DISABLE_CODEGEN'] == '1'
615
-
616
- if $REACT_CODEGEN_DISCOVERY_DONE
617
- Pod::UI.puts "[Codegen] Skipping use_react_native_codegen_discovery."
618
- return
619
- end
620
-
621
- Pod::UI.warn '[Codegen] warn: using experimental new codegen integration'
622
- react_native_path = options[:react_native_path] ||= "../node_modules/react-native"
623
- app_path = options[:app_path]
624
- fabric_enabled = options[:fabric_enabled] ||= false
625
- config_file_dir = options[:config_file_dir] ||= ''
626
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
627
-
628
- if !app_path
629
- Pod::UI.warn '[Codegen] Error: app_path is required for use_react_native_codegen_discovery.'
630
- 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!`.'
631
- exit 1
632
- end
633
-
634
- # Generate React-Codegen podspec here to add the script phases.
635
- script_phases = get_react_codegen_script_phases(options)
636
- react_codegen_spec = get_react_codegen_spec(fabric_enabled: fabric_enabled, script_phases: script_phases)
637
- generate_react_codegen_podspec!(react_codegen_spec)
638
-
639
- out = Pod::Executable.execute_command(
640
- 'node',
641
- [
642
- "#{relative_installation_root}/#{react_native_path}/scripts/generate-artifacts.js",
643
- "-p", "#{app_path}",
644
- "-o", Pod::Config.instance.installation_root,
645
- "-e", "#{fabric_enabled}",
646
- "-c", "#{config_file_dir}",
647
- ])
648
- Pod::UI.puts out;
649
-
650
- $REACT_CODEGEN_DISCOVERY_DONE = true
651
- end
652
-
653
- def use_react_native_codegen!(spec, options={})
654
- return if ENV['USE_CODEGEN_DISCOVERY'] == '1'
655
- # TODO: Once the new codegen approach is ready for use, we should output a warning here to let folks know to migrate.
656
-
657
- # The prefix to react-native
658
- react_native_path = options[:react_native_path] ||= "../.."
659
-
660
- # Library name (e.g. FBReactNativeSpec)
661
- library_name = options[:library_name] ||= "#{spec.name.gsub('_','-').split('-').collect(&:capitalize).join}Spec"
662
- Pod::UI.puts "[Codegen] Found #{library_name}"
663
-
664
- relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
665
- output_dir = options[:output_dir] ||= $CODEGEN_OUTPUT_DIR
666
- output_dir_module = "#{output_dir}/#{$CODEGEN_MODULE_DIR}"
667
- output_dir_component = "#{output_dir}/#{$CODEGEN_COMPONENT_DIR}"
668
-
669
- codegen_config = {
670
- "modules" => {
671
- :js_srcs_pattern => "Native*.js",
672
- :generated_dir => "#{relative_installation_root}/#{output_dir_module}/#{library_name}",
673
- :generated_files => [
674
- "#{library_name}.h",
675
- "#{library_name}-generated.mm"
676
- ]
677
- },
678
- "components" => {
679
- :js_srcs_pattern => "*NativeComponent.js",
680
- :generated_dir => "#{relative_installation_root}/#{output_dir_component}/#{library_name}",
681
- :generated_files => [
682
- "ComponentDescriptors.h",
683
- "EventEmitters.cpp",
684
- "EventEmitters.h",
685
- "Props.cpp",
686
- "Props.h",
687
- "RCTComponentViewHelpers.h",
688
- "ShadowNodes.cpp",
689
- "ShadowNodes.h"
690
- ]
691
- }
692
- }
693
-
694
- # The path to JavaScript files
695
- js_srcs_dir = options[:js_srcs_dir] ||= "./"
696
- library_type = options[:library_type]
697
-
698
- if library_type
699
- if !codegen_config[library_type]
700
- raise "[Codegen] invalid library_type: #{library_type}. Check your podspec to make sure it's set to 'modules' or 'components'. Removing the option will generate files for both"
701
- end
702
- js_srcs_pattern = codegen_config[library_type][:js_srcs_pattern]
703
- end
704
-
705
- if library_type
706
- generated_dirs = [ codegen_config[library_type][:generated_dir] ]
707
- generated_files = codegen_config[library_type][:generated_files].map { |filename| "#{codegen_config[library_type][:generated_dir]}/#{filename}" }
708
- else
709
- generated_dirs = [ codegen_config["modules"][:generated_dir], codegen_config["components"][:generated_dir] ]
710
- generated_files = codegen_config["modules"][:generated_files].map { |filename| "#{codegen_config["modules"][:generated_dir]}/#{filename}" }
711
- generated_files = generated_files.concat(codegen_config["components"][:generated_files].map { |filename| "#{codegen_config["components"][:generated_dir]}/#{filename}" })
712
- end
713
-
714
- if js_srcs_pattern
715
- file_list = `find #{js_srcs_dir} -type f -name #{js_srcs_pattern}`.split("\n").sort
716
- input_files = file_list.map { |filename| "${PODS_TARGET_SRCROOT}/#{filename}" }
717
- else
718
- input_files = [ js_srcs_dir ]
719
- end
720
-
721
- # Prepare filesystem by creating empty files that will be picked up as references by CocoaPods.
722
- prepare_command = "mkdir -p #{generated_dirs.join(" ")} && touch -a #{generated_files.join(" ")}"
723
- system(prepare_command) # Always run prepare_command when a podspec uses the codegen, as CocoaPods may skip invoking this command in certain scenarios. Replace with pre_integrate_hook after updating to CocoaPods 1.11
724
- spec.prepare_command = prepare_command
725
-
726
- spec.script_phase = {
727
- :name => 'Generate Specs',
728
- :input_files => input_files, # This also needs to be relative to Xcode
729
- :output_files => ["${DERIVED_FILE_DIR}/codegen-#{library_name}.log"].concat(generated_files.map { |filename| "${PODS_TARGET_SRCROOT}/#{filename}"} ),
730
- # The final generated files will be created when this script is invoked at Xcode build time.
731
- :script => get_script_phases_no_codegen_discovery(
732
- react_native_path: react_native_path,
733
- codegen_output_dir: $CODEGEN_OUTPUT_DIR,
734
- codegen_module_dir: $CODEGEN_MODULE_DIR,
735
- codegen_component_dir: $CODEGEN_COMPONENT_DIR,
736
- library_name: library_name,
737
- library_type: library_type,
738
- js_srcs_pattern: js_srcs_pattern,
739
- js_srcs_dir: js_srcs_dir,
740
- file_list: file_list
741
- ),
742
- :execution_position => :before_compile,
743
- :show_env_vars_in_log => true
744
- }
745
- end
746
-
747
- # This provides a post_install workaround for build issues related Xcode 12.5 and Apple Silicon (M1) machines.
748
- # Call this in the app's main Podfile's post_install hook.
749
- # See https://github.com/facebook/react-native/issues/31480#issuecomment-902912841 for more context.
750
- # Actual fix was authored by https://github.com/mikehardy.
751
- # New app template will call this for now until the underlying issue is resolved.
752
- def __apply_Xcode_12_5_M1_post_install_workaround(installer)
753
- # Flipper podspecs are still targeting an older iOS deployment target, and may cause an error like:
754
- # "error: thread-local storage is not supported for the current target"
755
- # The most reliable known workaround is to bump iOS deployment target to match react-native (iOS 11 now).
756
- installer.pods_project.targets.each do |target|
757
- target.build_configurations.each do |config|
758
- # ensure IPHONEOS_DEPLOYMENT_TARGET is at least 11.0
759
- deployment_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f
760
- should_upgrade = deployment_target < 11.0 && deployment_target != 0.0
761
- if should_upgrade
762
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
763
- end
764
- end
765
- end
766
-
767
- # But... doing so caused another issue in Flipper:
768
- # "Time.h:52:17: error: typedef redefinition with different types"
769
- # We need to make a patch to RCT-Folly - remove the `__IPHONE_OS_VERSION_MIN_REQUIRED` check.
770
- # See https://github.com/facebook/flipper/issues/834 for more details.
771
- time_header = "#{Pod::Config.instance.installation_root.to_s}/Pods/RCT-Folly/folly/portability/Time.h"
772
- `sed -i -e $'s/ && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)//' #{time_header}`
773
- end