Podfile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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', '3.5.0'
  66. # pod 'Google-Maps-iOS-Utils', '2.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. use_react_native!(
  75. :path => config[:reactNativePath],
  76. # Hermes is now enabled by default. Disable by setting this flag to false.
  77. :hermes_enabled => flags[:hermes_enabled],
  78. :fabric_enabled => flags[:fabric_enabled],
  79. # Enables Flipper.
  80. #
  81. # Note that if you have use_frameworks! enabled, Flipper will not work and
  82. # you should disable the next line.
  83. :flipper_configuration => flipper_config,
  84. # An absolute path to your application root.
  85. :app_path => "#{Pod::Config.instance.installation_root}/.."
  86. )
  87. target 'StridesTests' do
  88. inherit! :complete
  89. # Pods for testing
  90. end
  91. # Enables Flipper.
  92. #
  93. # Note that if you have use_frameworks! enabled, Flipper will not work and
  94. # you should disable the next line.
  95. # use_flipper!()
  96. # use_flipper!({'Flipper' => '0.182.0', 'Flipper-Folly' => '2.6.10', 'Flipper-RSocket' => '1.3.1'})
  97. #post_install do |installer|
  98. # react_native_post_install(installer)
  99. #end
  100. #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
  101. # post_install do |installer|
  102. # react_native_post_install(installer)
  103. # fix_library_search_paths(installer)
  104. # installer.pods_project.build_configurations.each do |config|
  105. # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  106. # end
  107. #end
  108. post_install do |installer|
  109. react_native_post_install(
  110. installer,
  111. config[:reactNativePath],
  112. :mac_catalyst_enabled => false
  113. )
  114. fix_library_search_paths(installer)
  115. installer.pods_project.build_configurations.each do |config|
  116. config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  117. config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
  118. end
  119. installer.pods_project.targets.each do |target|
  120. target.build_configurations.each do |config|
  121. config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  122. #config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
  123. end
  124. end
  125. __apply_Xcode_12_5_M1_post_install_workaround(installer)
  126. # 修复iOS 18编译问题
  127. bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
  128. def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
  129. framework_path = File.join(Dir.pwd, framework_relative_path)
  130. command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
  131. puts "Stripping bitcode: #{command}"
  132. system(command)
  133. end
  134. framework_paths = [
  135. #"Pods/LogRocket/LogRocket.xcframework/ios-arm64/LogRocket.framework/LogRocket",
  136. "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/hermes",
  137. "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/Versions/Current/hermes",
  138. "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64/hermes.framework/hermes",
  139. "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64_x86_64-maccatalyst/hermes.framework/hermes"
  140. ]
  141. framework_paths.each do |framework_relative_path|
  142. strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
  143. end
  144. end
  145. end
  146. def fix_library_search_paths(installer)
  147. def fix_config(config)
  148. lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
  149. if lib_search_paths
  150. 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)\"")
  151. # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
  152. # since the libraries there are only built for x86_64 and i386.
  153. lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
  154. lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
  155. if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
  156. # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
  157. lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
  158. end
  159. end
  160. end
  161. end
  162. end
  163. # projects = installer.aggregate_targets
  164. # .map{ |t| t.user_project }
  165. # .uniq{ |p| p.path }
  166. # .push(installer.pods_project)
  167. # projects.each do |project|
  168. # project.build_configurations.each do |config|
  169. # fix_config(config)
  170. # end
  171. # project.native_targets.each do |target|
  172. # target.build_configurations.each do |config|
  173. # fix_config(config)
  174. # end
  175. # end
  176. # project.save()
  177. # end