Advertisement
Nurrohman110

Untitled

Feb 9th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. # Uncomment this line to define a global platform for your project
  2. platform :ios, '9.0'
  3.  
  4. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
  5. ENV['COCOAPODS_DISABLE_STATS'] = 'true'
  6.  
  7. project 'Runner', {
  8. 'Debug' => :debug,
  9. 'Profile' => :release,
  10. 'Release' => :release,
  11. }
  12.  
  13. # add the Firebase pod for Google Analytics
  14. pod 'Firebase/Analytics'
  15. # add pods for any other desired Firebase products
  16. # https://firebase.google.com/docs/ios/setup#available-pods
  17.  
  18. def flutter_root
  19. generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  20. unless File.exist?(generated_xcode_build_settings_path)
  21. raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  22. end
  23.  
  24. File.foreach(generated_xcode_build_settings_path) do |line|
  25. matches = line.match(/FLUTTER_ROOT\=(.*)/)
  26. return matches[1].strip if matches
  27. end
  28. raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
  29. end
  30.  
  31. require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
  32.  
  33. flutter_ios_podfile_setup
  34.  
  35. # target 'Runner' do
  36. # use_frameworks!
  37. # use_modular_headers!
  38.  
  39. # flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  40. # end
  41.  
  42. # post_install do |installer|
  43. # installer.pods_project.targets.each do |target|
  44. # flutter_additional_ios_build_settings(target)
  45. # end
  46. # end
  47.  
  48. def parse_KV_file(file, separator='=')
  49. file_abs_path = File.expand_path(file)
  50. if !File.exists? file_abs_path
  51. return [];
  52. end
  53. generated_key_values = {}
  54. skip_line_start_symbols = ["#", "/"]
  55. File.foreach(file_abs_path) do |line|
  56. next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
  57. plugin = line.split(pattern=separator)
  58. if plugin.length == 2
  59. podname = plugin[0].strip()
  60. path = plugin[1].strip()
  61. podpath = File.expand_path("#{path}", file_abs_path)
  62. generated_key_values[podname] = podpath
  63. else
  64. puts "Invalid plugin specification: #{line}"
  65. end
  66. end
  67. generated_key_values
  68. end
  69.  
  70. target 'Runner' do
  71. use_frameworks!
  72. use_modular_headers!
  73.  
  74. # Flutter Pod
  75.  
  76. copied_flutter_dir = File.join(__dir__, 'Flutter')
  77. copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  78. copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  79. unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
  80. # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
  81. # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
  82. # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
  83.  
  84. generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
  85. unless File.exist?(generated_xcode_build_settings_path)
  86. raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  87. end
  88. generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
  89. cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
  90.  
  91. unless File.exist?(copied_framework_path)
  92. FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
  93. end
  94. unless File.exist?(copied_podspec_path)
  95. FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
  96. end
  97. end
  98.  
  99. # Added by jimmy
  100. # add the Firebase pod for Google Analytics && admob
  101. pod 'Firebase/Analytics'
  102. pod 'Firebase/AdMob'
  103.  
  104. # Keep pod path relative so it can be checked into Podfile.lock.
  105. pod 'Flutter', :path => 'Flutter'
  106.  
  107. # Plugin Pods
  108.  
  109. # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  110. # referring to absolute paths on developers' machines.
  111. system('rm -rf .symlinks')
  112. system('mkdir -p .symlinks/plugins')
  113. plugin_pods = parse_KV_file('../.flutter-plugins')
  114. plugin_pods.each do |name, path|
  115. symlink = File.join('.symlinks', 'plugins', name)
  116. File.symlink(path, symlink)
  117. pod name, :path => File.join(symlink, 'ios')
  118. end
  119. end
  120.  
  121. # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
  122. install! 'cocoapods', :disable_input_output_paths => true
  123.  
  124. post_install do |pi|
  125. pi.pods_project.targets.each do |t|
  126. t.build_configurations.each do |config|
  127. # config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
  128. config.build_settings['SWIFT_VERSION'] = '4.2' # required by simple_permission
  129. config.build_settings['ENABLE_BITCODE'] = 'NO'
  130. config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
  131. '$(inherited)',
  132.  
  133. ## dart: PermissionGroup.calendar
  134. # 'PERMISSION_EVENTS=0',
  135.  
  136. ## dart: PermissionGroup.reminders
  137. # 'PERMISSION_REMINDERS=0',
  138.  
  139. ## dart: PermissionGroup.contacts
  140. # 'PERMISSION_CONTACTS=0',
  141.  
  142. ## dart: PermissionGroup.camera
  143. # 'PERMISSION_CAMERA=0',
  144.  
  145. ## dart: PermissionGroup.microphone
  146. # 'PERMISSION_MICROPHONE=0',
  147.  
  148. ## dart: PermissionGroup.speech
  149. # 'PERMISSION_SPEECH_RECOGNIZER=0',
  150.  
  151. ## dart: PermissionGroup.photos
  152. # 'PERMISSION_PHOTOS=0',
  153.  
  154. ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
  155. # 'PERMISSION_LOCATION=0',
  156.  
  157. ## dart: PermissionGroup.notification
  158. # 'PERMISSION_NOTIFICATIONS=0',
  159.  
  160. ## dart: PermissionGroup.mediaLibrary
  161. # 'PERMISSION_MEDIA_LIBRARY=0',
  162.  
  163. ## dart: PermissionGroup.sensors
  164. # 'PERMISSION_SENSORS=0'
  165. ]
  166. end
  167. end
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement