Flutter-iOS;应用已运行但无法存档

时间:2018-12-06 07:32:39

标签: ios xcode flutter

当我的应用程序通过命令行(flutter运行)并在xCode中运行时,我遇到一种奇怪的情况,但是当我选择“ Generic iOS Device”进行存档时,出现错误:

  找不到

'shared_preferences / SharedPreferencesPlugin.h'文件

我尝试了与Github和此处推荐的与插件问题相关的其他方法。例如,这个:

  1. xCode->项目->清理
  2. 已删除Podfile.lock和目录Pods
  3. pod安装
  4. 颤动干净,颤动

一切正常,直到我尝试存档为止。

这是我的Podfile(我根据以下示例完成了此操作:https://github.com/flutter/flutter/issues/15409#issuecomment-387063765

# 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
  use_frameworks!

  # 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 packages 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

pre_install do |installer|
  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
    # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
    target.headers_build_phase.files.each do |file|
      file.settings = { 'ATTRIBUTES' => ['Public'] }
    end
  end
end

这是我扑扑的医生:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.13, on Mac OS X 10.13.6 17G65, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[!] Android Studio (not installed)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

我还检查过this question有关在xCode中进行归档的问题,但没有找到答案。

你有什么想法做什么?

预先感谢您的支持。

4 个答案:

答案 0 :(得分:1)

我通过运行flutter build ios解决了这个问题,然后开始存档。 Flutter构建ios下载并升级了一些构建工具。我认为是造成这个问题的原因。

答案 1 :(得分:0)

临时解决方案是使用命令行进行构建,但是在Xcode中进行构建的问题仍然存在

答案 2 :(得分:0)

删除 / ios 目录中的所有 Pod文件,然后在/ ios目录中运行以下命令:

sudo pod init
sudo gem install cocoapods
sudo pod install

答案 3 :(得分:0)

您可能想要尝试删除ios文件夹并重新生成项目,然后查看错误是否消失:

颤动创建。

希望获得帮助,自从Xcode 11.4进行新更新以来,几周前我在一个项目上遇到了崩溃,这种方法对我有帮助