ios - 不知道在哪里添加pod文件flutter ios安装
问题描述
我正在开发一个带有 firebase 后端的颤振项目,并试图将我的项目的 ios 方面添加到一个 firebase 项目中。说明说要添加以下豆荚:
# 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 目录中。但是,例如,仅将该文件下载到正确的文件夹中是不够的。
推荐阅读
- python-3.x - 在 pipenv 中安装 twisted 时出错
- angular - Bitbucket Angular npm 运行构建失败
- c++ - 如何将 ostringstream 十六进制字符串字符对转换为单个 unit8_t 等效二进制值
- nginx - 目录的内容配置
- django - Django 管理员显示创建的实例,但在 DRF 视图中看不到它
- javascript - JavaScript 等待承诺
- javascript - 在 React 应用程序中使用 useState 更新路由器值时出现太多重新渲染错误
- java - 用于读取的带有 Java 的 Spark Cassandra 连接器
- wpf - Appium Windows Driver - 完成后按下Ctrl
- sql - 使用 Excel 或 SQL 根据电子邮件地址创建单独的列