Advertisement
sskss73

Untitled

Mar 30th, 2020
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.37 KB | None | 0 0
  1. # Uncomment this line to define a global platform for your project
  2.  platform :ios, '10'
  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. def parse_KV_file(file, separator='=')
  14.   file_abs_path = File.expand_path(file)
  15.   if !File.exists? file_abs_path
  16.     return [];
  17.   end
  18.   generated_key_values = {}
  19.   skip_line_start_symbols = ["#", "/"]
  20.   File.foreach(file_abs_path) do |line|
  21.     next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
  22.     plugin = line.split(pattern=separator)
  23.     if plugin.length == 2
  24.       podname = plugin[0].strip()
  25.       path = plugin[1].strip()
  26.       podpath = File.expand_path("#{path}", file_abs_path)
  27.       generated_key_values[podname] = podpath
  28.     else
  29.       puts "Invalid plugin specification: #{line}"
  30.     end
  31.   end
  32.   generated_key_values
  33. end
  34.  
  35. target 'Runner' do
  36.   # Flutter Pod
  37.  
  38.   copied_flutter_dir = File.join(__dir__, 'Flutter')
  39.   copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  40.   copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  41.   unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
  42.     # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
  43.     # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
  44.     # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
  45.  
  46.     generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
  47.     unless File.exist?(generated_xcode_build_settings_path)
  48.       raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  49.     end
  50.     generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
  51.     cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
  52.  
  53.     unless File.exist?(copied_podspec_path)
  54.       FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
  55.     end
  56.   end
  57.  
  58.   # Keep pod path relative so it can be checked into Podfile.lock.
  59.   pod 'Flutter', :path => 'Flutter'
  60.  
  61.   # Plugin Pods
  62.  
  63.   # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  64.   # referring to absolute paths on developers' machines.
  65.  system('rm -rf .symlinks')
  66.  system('mkdir -p .symlinks/plugins')
  67.  plugin_pods = parse_KV_file('../.flutter-plugins')
  68.  plugin_pods.each do |name, path|
  69.    symlink = File.join('.symlinks', 'plugins', name)
  70.    File.symlink(path, symlink)
  71.    pod name, :path => File.join(symlink, 'ios')
  72.  end
  73. end
  74.  
  75. post_install do |installer|
  76.  installer.pods_project.targets.each do |target|
  77.    target.build_configurations.each do |config|
  78.      config.build_settings['ENABLE_BITCODE'] = 'NO'
  79.  
  80.      # You can remove unused permissions here
  81.      # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/ios/Classes/PermissionHandlerEnums.h
  82.      # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
  83.       config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
  84.         '$(inherited)',
  85.  
  86.         ## dart: PermissionGroup.calendar
  87.         'PERMISSION_EVENTS=0',
  88.  
  89.         ## dart: PermissionGroup.reminders
  90.         'PERMISSION_REMINDERS=0',
  91.  
  92.         ## dart: PermissionGroup.contacts
  93.         'PERMISSION_CONTACTS=0',
  94.  
  95.         ## dart: PermissionGroup.camera
  96.         'PERMISSION_CAMERA=0',
  97.  
  98.         ## dart: PermissionGroup.microphone
  99.         'PERMISSION_MICROPHONE=0',
  100.  
  101.         ## dart: PermissionGroup.speech
  102.         'PERMISSION_SPEECH_RECOGNIZER=0',
  103.  
  104.         ## dart: PermissionGroup.photos
  105.         'PERMISSION_PHOTOS=0',
  106.  
  107.         ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
  108.         'PERMISSION_LOCATION=0',
  109.  
  110.         ## dart: PermissionGroup.notification
  111.         'PERMISSION_NOTIFICATIONS=1',
  112.  
  113.         ## dart: PermissionGroup.mediaLibrary
  114.         'PERMISSION_MEDIA_LIBRARY=0',
  115.  
  116.         ## dart: PermissionGroup.sensors
  117.         'PERMISSION_SENSORS=0'
  118.       ]
  119.  
  120.     end
  121.   end
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement