Podfile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. flipper_config = FlipperConfiguration.disabled;
  31. linkage = ENV['USE_FRAMEWORKS']
  32. if linkage != nil
  33. Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  34. use_frameworks! :linkage => linkage.to_sym
  35. end
  36. #权限处理
  37. setup_permissions([
  38. 'AppTrackingTransparency', #访问设备的广告标识符
  39. # 'BluetoothPeripheral', #访问蓝牙
  40. # 'Calendars', #访问日历
  41. 'Camera', #访问相机
  42. # 'Contacts', #访问联系人
  43. # 'FaceID', #访问FaceID
  44. 'LocationAccuracy', #访问高精度定位
  45. # 'LocationAlways', #始终访问位置信息
  46. 'LocationWhenInUse', #在使用中访问位置信息
  47. # 'MediaLibrary', #使用媒体库
  48. # 'Microphone', #使用麦克风
  49. # 'Motion', #运动权限
  50. 'Notifications', #使用通知
  51. 'PhotoLibrary', #使用照片库
  52. 'PhotoLibraryAddOnly', #添加照片
  53. # 'Reminders',
  54. # 'SpeechRecognition',
  55. # 'StoreKit'
  56. ])
  57. target 'Strides' do
  58. config = use_native_modules!
  59. # Flags change depending on the env values.
  60. flags = get_default_flags()
  61. # 谷歌地图服务
  62. #pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
  63. rn_maps_path = '../node_modules/react-native-maps'
  64. pod 'react-native-google-maps', :path => rn_maps_path
  65. pod 'GoogleMaps', '7.4.0'
  66. pod 'Google-Maps-iOS-Utils', '4.1.0'
  67. # 谷歌通知启用
  68. # pod 'FirebaseAuth'
  69. pod 'FirebaseCore'
  70. pod 'FirebaseAnalytics'
  71. pod 'FirebaseMessaging'
  72. # pod 'FirebaseFirestore'
  73. pod 'GoogleUtilities', :modular_headers => true
  74. pod 'TOCropViewController', '2.6.1'
  75. use_react_native!(
  76. :path => config[:reactNativePath],
  77. # Hermes is now enabled by default. Disable by setting this flag to false.
  78. :hermes_enabled => flags[:hermes_enabled],
  79. :fabric_enabled => flags[:fabric_enabled],
  80. # Enables Flipper.
  81. #
  82. # Note that if you have use_frameworks! enabled, Flipper will not work and
  83. # you should disable the next line.
  84. :flipper_configuration => flipper_config,
  85. # An absolute path to your application root.
  86. :app_path => "#{Pod::Config.instance.installation_root}/.."
  87. )
  88. target 'StridesTests' do
  89. inherit! :complete
  90. # Pods for testing
  91. end
  92. # Enables Flipper.
  93. #
  94. # Note that if you have use_frameworks! enabled, Flipper will not work and
  95. # you should disable the next line.
  96. # use_flipper!()
  97. # use_flipper!({'Flipper' => '0.182.0', 'Flipper-Folly' => '2.6.10', 'Flipper-RSocket' => '1.3.1'})
  98. #post_install do |installer|
  99. # react_native_post_install(installer)
  100. #end
  101. #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
  102. # post_install do |installer|
  103. # react_native_post_install(installer)
  104. # fix_library_search_paths(installer)
  105. # installer.pods_project.build_configurations.each do |config|
  106. # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  107. # end
  108. #end
  109. post_install do |installer|
  110. react_native_post_install(
  111. installer,
  112. config[:reactNativePath],
  113. :mac_catalyst_enabled => false
  114. )
  115. fix_library_search_paths(installer)
  116. installer.pods_project.build_configurations.each do |config|
  117. config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  118. config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
  119. end
  120. installer.pods_project.targets.each do |target|
  121. target.build_configurations.each do |config|
  122. config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  123. #config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
  124. end
  125. end
  126. __apply_Xcode_12_5_M1_post_install_workaround(installer)
  127. # 修复iOS 18编译问题
  128. bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
  129. def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
  130. framework_path = File.join(Dir.pwd, framework_relative_path)
  131. command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
  132. puts "Stripping bitcode: #{command}"
  133. system(command)
  134. end
  135. framework_paths = [
  136. #"Pods/LogRocket/LogRocket.xcframework/ios-arm64/LogRocket.framework/LogRocket",
  137. "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/hermes",
  138. "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/Versions/Current/hermes",
  139. "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64/hermes.framework/hermes",
  140. "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64_x86_64-maccatalyst/hermes.framework/hermes"
  141. ]
  142. framework_paths.each do |framework_relative_path|
  143. strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
  144. end
  145. end
  146. end
  147. def fix_library_search_paths(installer)
  148. def fix_config(config)
  149. lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
  150. if lib_search_paths
  151. 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)\"")
  152. # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
  153. # since the libraries there are only built for x86_64 and i386.
  154. lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
  155. lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
  156. if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
  157. # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
  158. lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
  159. end
  160. end
  161. end
  162. end
  163. end
  164. # projects = installer.aggregate_targets
  165. # .map{ |t| t.user_project }
  166. # .uniq{ |p| p.path }
  167. # .push(installer.pods_project)
  168. # projects.each do |project|
  169. # project.build_configurations.each do |config|
  170. # fix_config(config)
  171. # end
  172. # project.native_targets.each do |target|
  173. # target.build_configurations.each do |config|
  174. # fix_config(config)
  175. # end
  176. # end
  177. # project.save()
  178. # end