require_relative '../node_modules/react-native/scripts/react_native_pods.rb' # Resolve react_native_pods.rb with node to allow for hoisting def node_require(script) # Resolve script with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', "require.resolve( '#{script}', {paths: [process.argv[1]]}, )", __dir__]).strip end #node_require('react-native/scripts/react_native_pods.rb') node_require('react-native-permissions/scripts/setup.rb') platform :ios, '15.1' prepare_react_native_project! # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded # # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` # ```js # module.exports = { # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` #flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled #flipper_config = FlipperConfiguration.disabled; linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end #权限处理 setup_permissions([ 'AppTrackingTransparency', #访问设备的广告标识符 # 'BluetoothPeripheral', #访问蓝牙 # 'Calendars', #访问日历 'Camera', #访问相机 # 'Contacts', #访问联系人 # 'FaceID', #访问FaceID 'LocationAccuracy', #访问高精度定位 # 'LocationAlways', #始终访问位置信息 'LocationWhenInUse', #在使用中访问位置信息 # 'MediaLibrary', #使用媒体库 # 'Microphone', #使用麦克风 # 'Motion', #运动权限 'Notifications', #使用通知 'PhotoLibrary', #使用照片库 'PhotoLibraryAddOnly', #添加照片 # 'Reminders', # 'SpeechRecognition', # 'StoreKit' ]) target 'ChargEco' do config = use_native_modules! use_react_native!( :path => config[:reactNativePath], :fabric_enabled => true, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) # 谷歌地图服务 # pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon' rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-maps/Google', :path => rn_maps_path # pod 'GoogleMaps', '3.5.0' # pod 'Google-Maps-iOS-Utils', '2.1.0' # 谷歌通知启用 # pod 'FirebaseAuth' pod 'FirebaseCore' pod 'FirebaseAnalytics' pod 'FirebaseMessaging' pod 'FirebaseCrashlytics' pod 'GoogleDataTransport', :modular_headers => true pod 'nanopb', :modular_headers => true # pod 'FirebaseFirestore' pod 'GoogleUtilities', :modular_headers => true # target 'StridesTests' do # inherit! :complete # # Pods for testing # end post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'fmt' target.build_configurations.each do |config| # 1. 强制禁用 consteval,回退到运行时检查或旧版编译器行为 config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)'] config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'FMT_USE_CONSTEVAL=0' end end end # 2. 针对源码文件进行物理补丁(确保万无一失) fmt_base = File.join(installer.sandbox.root, 'fmt', 'include', 'fmt', 'base.h') if File.exist?(fmt_base) content = File.read(fmt_base) unless content.include?('// Xcode 26 workaround') puts "Patching fmt/base.h for Xcode 26.4 compatibility..." # 将检测到的 consteval 支持强制设为 0 patched = content.gsub('# define FMT_USE_CONSTEVAL 1', "# define FMT_USE_CONSTEVAL 0 // Xcode 26 workaround") File.chmod(0644, fmt_base) File.write(fmt_base, patched) end end # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false, # :ccache_enabled => true ) end end