Podfile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. require_relative '../node_modules/react-native/scripts/react_native_pods.rb'
  2. # Resolve react_native_pods.rb with node to allow for hoisting
  3. def node_require(script)
  4. # Resolve script with node to allow for hoisting
  5. require Pod::Executable.execute_command('node', ['-p',
  6. "require.resolve(
  7. '#{script}',
  8. {paths: [process.argv[1]]},
  9. )", __dir__]).strip
  10. end
  11. #node_require('react-native/scripts/react_native_pods.rb')
  12. node_require('react-native-permissions/scripts/setup.rb')
  13. platform :ios, '15.1'
  14. prepare_react_native_project!
  15. # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
  16. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
  17. #
  18. # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
  19. # ```js
  20. # module.exports = {
  21. # dependencies: {
  22. # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
  23. # ```
  24. #flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
  25. #flipper_config = FlipperConfiguration.disabled;
  26. linkage = ENV['USE_FRAMEWORKS']
  27. if linkage != nil
  28. Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  29. use_frameworks! :linkage => linkage.to_sym
  30. end
  31. #权限处理
  32. setup_permissions([
  33. 'AppTrackingTransparency', #访问设备的广告标识符
  34. # 'BluetoothPeripheral', #访问蓝牙
  35. # 'Calendars', #访问日历
  36. 'Camera', #访问相机
  37. # 'Contacts', #访问联系人
  38. # 'FaceID', #访问FaceID
  39. 'LocationAccuracy', #访问高精度定位
  40. # 'LocationAlways', #始终访问位置信息
  41. 'LocationWhenInUse', #在使用中访问位置信息
  42. # 'MediaLibrary', #使用媒体库
  43. # 'Microphone', #使用麦克风
  44. # 'Motion', #运动权限
  45. 'Notifications', #使用通知
  46. 'PhotoLibrary', #使用照片库
  47. 'PhotoLibraryAddOnly', #添加照片
  48. # 'Reminders',
  49. # 'SpeechRecognition',
  50. # 'StoreKit'
  51. ])
  52. target 'ChargEco' do
  53. config = use_native_modules!
  54. use_react_native!(
  55. :path => config[:reactNativePath],
  56. :fabric_enabled => true,
  57. # An absolute path to your application root.
  58. :app_path => "#{Pod::Config.instance.installation_root}/.."
  59. )
  60. # 谷歌地图服务
  61. # pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
  62. rn_maps_path = '../node_modules/react-native-maps'
  63. pod 'react-native-maps/Google', :path => rn_maps_path
  64. # pod 'GoogleMaps', '3.5.0'
  65. # pod 'Google-Maps-iOS-Utils', '2.1.0'
  66. # 谷歌通知启用
  67. # pod 'FirebaseAuth'
  68. pod 'FirebaseCore'
  69. pod 'FirebaseAnalytics'
  70. pod 'FirebaseMessaging'
  71. pod 'FirebaseCrashlytics'
  72. pod 'GoogleDataTransport', :modular_headers => true
  73. pod 'nanopb', :modular_headers => true
  74. # pod 'FirebaseFirestore'
  75. pod 'GoogleUtilities', :modular_headers => true
  76. # target 'StridesTests' do
  77. # inherit! :complete
  78. # # Pods for testing
  79. # end
  80. post_install do |installer|
  81. installer.pods_project.targets.each do |target|
  82. if target.name == 'fmt'
  83. target.build_configurations.each do |config|
  84. # 1. 强制禁用 consteval,回退到运行时检查或旧版编译器行为
  85. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
  86. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'FMT_USE_CONSTEVAL=0'
  87. end
  88. end
  89. end
  90. # 2. 针对源码文件进行物理补丁(确保万无一失)
  91. fmt_base = File.join(installer.sandbox.root, 'fmt', 'include', 'fmt', 'base.h')
  92. if File.exist?(fmt_base)
  93. content = File.read(fmt_base)
  94. unless content.include?('// Xcode 26 workaround')
  95. puts "Patching fmt/base.h for Xcode 26.4 compatibility..."
  96. # 将检测到的 consteval 支持强制设为 0
  97. patched = content.gsub('# define FMT_USE_CONSTEVAL 1', "# define FMT_USE_CONSTEVAL 0 // Xcode 26 workaround")
  98. File.chmod(0644, fmt_base)
  99. File.write(fmt_base, patched)
  100. end
  101. end
  102. # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
  103. react_native_post_install(
  104. installer,
  105. config[:reactNativePath],
  106. :mac_catalyst_enabled => false,
  107. # :ccache_enabled => true
  108. )
  109. end
  110. end