我正在做一个有Firebase后端的Flutter 项目,并试图将我的项目的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文件吗?

推荐答案

您希望将这些行添加到"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目录即可.但是,例如,仅仅将该文件下载到正确的文件夹中是不够的.

Flutter相关问答推荐

当仅点击一行时,所有行都被选中

获取屏幕大小的滚动视图与动态大小?

无法在GroupButton内部正确呈现

Flutter—如何在Riverpod中使用全类状态?

如何使一个悬浮的appbar在flutter?

Flutter 隔离.使用多个参数运行

在选项卡栏视图中搜索和筛选不起作用

为什么Spotify Auth API返回400,而";code_verier不正确?

如何在 VS Code 中启用 Flutter 运行/调试工具栏?

Flutter如何从深入嵌套的小部件中打开抽屉?

从所有设备注销,因为用户帐户已从 firebase flutter 中删除

为什么我们使用 RiverpodGenerator

提供者、存储库和服务之间有什么区别?

如何制作flutter showDialog、AlertDialog屏障 colored颜色 渐变

转换函数上传文件上传Uint8List

我可以定义一次 sharedPreferences 并在需要数据显示到 flutter 应用程序时调用它吗?

为什么容器会填满整个空间?

我可以使用 Future 来填充Text() 小部件而不是在 Flutter 中使用 FutureBuilder 吗?

如何在Flutter 中根据其父小部件高度设置图标按钮飞溅半径

解密 Modulr 安全令牌