Podfile 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # Resolve react_native_pods.rb with node to allow for hoisting
  2. require Pod::Executable.execute_command('node', ['-p',
  3. 'require.resolve(
  4. "react-native/scripts/react_native_pods.rb",
  5. {paths: [process.argv[1]]},
  6. )', __dir__]).strip
  7. require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
  8. def node_require(script)
  9. # Resolve script with node to allow for hoisting
  10. require Pod::Executable.execute_command('node', ['-p',
  11. "require.resolve(
  12. '#{script}',
  13. {paths: [process.argv[1]]},
  14. )", __dir__]).strip
  15. end
  16. node_require('react-native/scripts/react_native_pods.rb')
  17. node_require('react-native-permissions/scripts/setup.rb')
  18. platform :ios, '13.0'
  19. prepare_react_native_project!
  20. # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
  21. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
  22. #
  23. # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
  24. # ```js
  25. # module.exports = {
  26. # dependencies: {
  27. # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
  28. # ```
  29. flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
  30. linkage = ENV['USE_FRAMEWORKS']
  31. if linkage != nil
  32. Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  33. use_frameworks! :linkage => linkage.to_sym
  34. end
  35. #权限处理
  36. setup_permissions([
  37. 'AppTrackingTransparency', #访问设备的广告标识符
  38. # 'BluetoothPeripheral', #访问蓝牙
  39. # 'Calendars', #访问日历
  40. 'Camera', #访问相机
  41. # 'Contacts', #访问联系人
  42. # 'FaceID', #访问FaceID
  43. 'LocationAccuracy', #访问高精度定位
  44. # 'LocationAlways', #始终访问位置信息
  45. 'LocationWhenInUse', #在使用中访问位置信息
  46. # 'MediaLibrary', #使用媒体库
  47. # 'Microphone', #使用麦克风
  48. # 'Motion', #运动权限
  49. 'Notifications', #使用通知
  50. 'PhotoLibrary', #使用照片库
  51. 'PhotoLibraryAddOnly', #添加照片
  52. # 'Reminders',
  53. # 'SpeechRecognition',
  54. # 'StoreKit'
  55. ])
  56. target 'Strides' do
  57. config = use_native_modules!
  58. # Flags change depending on the env values.
  59. flags = get_default_flags()
  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-google-maps', :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', :modular_headers => true
  69. pod 'FirebaseAnalytics'
  70. pod 'FirebaseMessaging'
  71. # pod 'FirebaseFirestore'
  72. pod 'GoogleUtilities', :modular_headers => true
  73. use_react_native!(
  74. :path => config[:reactNativePath],
  75. # Hermes is now enabled by default. Disable by setting this flag to false.
  76. :hermes_enabled => flags[:hermes_enabled],
  77. :fabric_enabled => flags[:fabric_enabled],
  78. # Enables Flipper.
  79. #
  80. # Note that if you have use_frameworks! enabled, Flipper will not work and
  81. # you should disable the next line.
  82. :flipper_configuration => flipper_config,
  83. # An absolute path to your application root.
  84. :app_path => "#{Pod::Config.instance.installation_root}/.."
  85. )
  86. target 'StridesTests' do
  87. inherit! :complete
  88. # Pods for testing
  89. end
  90. # Enables Flipper.
  91. #
  92. # Note that if you have use_frameworks! enabled, Flipper will not work and
  93. # you should disable the next line.
  94. # use_flipper!()
  95. # use_flipper!({'Flipper' => '0.182.0', 'Flipper-Folly' => '2.6.10', 'Flipper-RSocket' => '1.3.1'})
  96. #post_install do |installer|
  97. # react_native_post_install(installer)
  98. #end
  99. #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
  100. # post_install do |installer|
  101. # react_native_post_install(installer)
  102. # fix_library_search_paths(installer)
  103. # installer.pods_project.build_configurations.each do |config|
  104. # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  105. # end
  106. #end
  107. post_install do |installer|
  108. react_native_post_install(
  109. installer,
  110. config[:reactNativePath],
  111. :mac_catalyst_enabled => false
  112. )
  113. fix_library_search_paths(installer)
  114. installer.pods_project.build_configurations.each do |config|
  115. config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  116. config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
  117. end
  118. __apply_Xcode_12_5_M1_post_install_workaround(installer)
  119. end
  120. end
  121. def fix_library_search_paths(installer)
  122. def fix_config(config)
  123. lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
  124. if lib_search_paths
  125. 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)\"")
  126. # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
  127. # since the libraries there are only built for x86_64 and i386.
  128. lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
  129. lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
  130. if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
  131. # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
  132. lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
  133. end
  134. end
  135. end
  136. end
  137. # projects = installer.aggregate_targets
  138. # .map{ |t| t.user_project }
  139. # .uniq{ |p| p.path }
  140. # .push(installer.pods_project)
  141. # projects.each do |project|
  142. # project.build_configurations.each do |config|
  143. # fix_config(config)
  144. # end
  145. # project.native_targets.each do |target|
  146. # target.build_configurations.each do |config|
  147. # fix_config(config)
  148. # end
  149. # end
  150. # project.save()
  151. # end
  152. end