【问题标题】:Which is the right way to generate a Podfile in flutter?在颤动中生成 Podfile 的正确方法是什么?
【发布时间】:2021-05-23 13:17:54
【问题描述】:

对我来说,删除后生成pod文件有两种方法 第一个是通过运行flutter pub get,然后经过一些编辑会生成如下形式的pod文件

# Uncomment this line to define a global platform for your project
 platform :ios, '10.0'
pod 'Firebase/Analytics' #ATTENTION PLEASE SHOULD I ADD THESE PODS HERE?
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Database'
pod 'Firebase/Messaging'

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

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

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |pi|
    pi.pods_project.targets.each do |t|
      t.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0’
      end
    end
end

然后运行 ​​pod install


另一个实现是当我运行 pod init 时,我在一些编辑后得到以下内容:

# Uncomment the next line to define a global platform for your project
 platform :ios, '10.0'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Database'
pod 'Firebase/Messaging'

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Runner

end

post_install do |pi|
    pi.pods_project.targets.each do |t|
      t.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0’
      end
    end
end

然后运行 ​​pod install... 这是使用颤振并构建和运行 ios 应用程序的正确方法,因为我很困惑,我无法以 ios 形式运行我的应用程序。 更多详细信息在 issue 中,如果有人帮助我,我会很高兴

【问题讨论】:

    标签: ios swift flutter flutter-dependencies podfile


    【解决方案1】:

    好吧,你不必像在你的 Podfile 中那样安装 pod pod 'Firebase/Messaging' 只需将它们放在您的 pubspec 文件中,然后运行 ​​pod clean 然后删除您的 Podfile 然后运行 ​​flutter pub get 并且颤振将为您生成 Podfile,然后您应该取消注释第二行并运行 pod install 然后运行您的应用

    【讨论】:

      【解决方案2】:

      您是否尝试删除 pod 文件夹并运行 颤振获得酒吧 比 pod install 吗?

      【讨论】:

      • 它将生成提到的第一个 podfile。
      猜你喜欢
      • 1970-01-01
      • 2023-02-08
      • 2020-11-05
      • 2012-07-13
      • 2020-12-16
      • 1970-01-01
      • 1970-01-01
      • 2018-02-04
      • 2011-12-09
      相关资源
      最近更新 更多