【问题标题】:Don't know where to add pod files flutter ios installation不知道在哪里添加pod文件flutter ios安装
【发布时间】:2020-05-26 04:54:57
【问题描述】:

我正在开发一个带有 firebase 后端的颤振项目,并试图将我的项目的 ios 方面添加到一个 firebase 项目中。说明说要添加以下 pod:

# Add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'

# Add the pods for any other Firebase products you want to use in your app
# For example, to use Firebase Authentication and Cloud Firestore
pod 'Firebase/Auth'
pod 'Firebase/Firestore'

但问题是我不知道在文件中的何处写入这些内容。这是位于此处的文件(ios/Podfile)。更熟悉 ios 开发的人可以告诉我在哪里添加这些 pod 吗?谢谢!

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

再次感谢!我也可能有另一个文件。它们是指 Podfile.lock 文件吗?

【问题讨论】:

    标签: ios firebase flutter cocoapods firebase-analytics


    【解决方案1】:

    您希望将这些行添加到“Podfile”文件,而不是 Podfile.lock。您可以在开头或结尾添加该行,但将其添加到开头可能很好,因此您可以轻松查看默认文件是如何修改的。

    # Uncomment this line to define a global platform for your project
    # platform :ios, '9.0'
    
    pod 'Firebase/Analytics'
    pod 'Firebase/Auth'
    pod 'Firebase/Firestore'
    
    # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'
    
    project 'Runner', {
      'Debug' => :debug,
      'Profile' => :release,
      'Release' => :release,
    }
    
    ...
    

    要记住的另一件事是,在添加 GoogleServices-Info.plist 文件时,您必须在 xcode 中添加该文件。您可以将文件拖到 xcode 中的 Runner 目录中。但是,例如,仅将该文件下载到正确的文件夹中是不够的。

    【讨论】:

    • 谢谢@Kris!巨大的帮助!
    • 这样的小版本被拒绝了,但是...... 你必须在 xcode 中添加文件 值得加粗! xD 谢谢!
    • 我现在没有 xcode。我该怎么办?
    猜你喜欢
    • 2014-05-14
    • 2019-05-24
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多