Kyl*_* B. 6 ios flutter podfile flutter-dependencies
我有一个运行良好的颤振应用程序。我正在更新我的 flutter 版本和我的一些插件的版本(在最新的 XCode 版本 11 上)。我无法再构建我的应用程序,因为发生以下两种情况之一:
1)如果我没有“use_modular_headers!” 在我的 podfile 中,尝试运行时出现此错误pod install:
The Swift pod `DKPhotoGallery` depends upon `SDWebImage`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
Run Code Online (Sandbox Code Playgroud)
2)如果我添加“use_modular_headers!” 到 podfile,然后我可以成功安装 podfile,但是在构建时失败并出现此错误:
fatal error: module map file '/Users/mbpro/Documents/Perkl/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap' not found
Run Code Online (Sandbox Code Playgroud)
我发现的第二个错误是因为 GRPC 不支持模块化标题。这就是我卡住的地方,因为由于 flutter 从 pubspec 动态生成 podfile 的方式,似乎模块化标头是全局打开或关闭的,我无法专门为特定的 pod 打开模块化标头。
这是我的 pubspec 依赖项列表:
cloud_firestore: 0.13.6
firebase_auth: 0.16.1
firebase_core:
firebase_database:
firebase_storage:
firebase_messaging:
google_sign_in:
image_picker:
image_cropper:
intl:
flutter_sound:
flutter_launcher_icons:
flushbar:
file_picker:
path_provider:
#audioplayers:
provider:
sliding_up_panel:
font_awesome_flutter:
marquee:
Run Code Online (Sandbox Code Playgroud)
对此的任何帮助将不胜感激!!它完全关闭了我的开发,因为升级后我无法构建以测试任何东西。
编辑:Flutter Doctor -v 输出(一切看起来都很好)
[?] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale en-US)
• Flutter version 1.17.3 at /Users/mbpro/Downloads/flutter
• Framework revision b041144f83 (8 days ago), 2020-06-04 09:26:11 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[?] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mbpro/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[?] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.9.3
[?] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
[?] Connected device (1 available)
• iPhone SE (2nd generation) • 9FC22937-91AB-4F22-BB1E-20FFB1CAF4C8 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
• No issues found!
Run Code Online (Sandbox Code Playgroud)
经过很长时间的搜索,答案很简单。
1-导航到应用程序内的 ios 目录
2- 在文本编辑器中编辑 podfile
3-搜索 target 'Runner' do
4-use_frameworks!在下一行添加
5- 保存并运行您的应用
例如,在解决问题之前,我的完整podfile看起来像这样
# 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 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
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Run Code Online (Sandbox Code Playgroud)
通过添加额外的行解决问题后,它看起来像
# 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 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!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Run Code Online (Sandbox Code Playgroud)
小智 1
我一整天都在使用非常相似的插件列表来解决同样的问题。
使用这个答案: 使用带有 CocoaPods 1.5 的静态库导入时没有这样的模块
我能够按如下方式修改 flutter pod 并构建项目:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
inhibit_all_warnings! # ------------------> NEW
use_frameworks! # ------------------> NEW
dynamic_frameworks = ['BoringSSL-GRPC'] # ------------------> NEW
# 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
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |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)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end
target 'Runner' do
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# 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')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end
pre_install do |installer| # ------------------> NEW BLOCK
installer.pod_targets.each do |pod|
puts "Evaluating static framework for pod #{pod.name}"
if dynamic_frameworks.include?(pod.name)
puts "Overriding the static_framework method for #{pod.name}"
pod pod.name, :modular_headers => false
end
end
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
end
end
Run Code Online (Sandbox Code Playgroud)
这是我第一次在 IOS 中构建应用程序,总构建时间约为 35m (!),我不知道它是否与此修复有关,或者是其他什么。
还尝试执行相反的操作,所有动态和 DKPhotoGalley 静态,但这会使构建失败,并在 DKPhotoGallery 代码上出现错误。
如果有人可以提出更好的方法或理解根本问题,那就太好了。
| 归档时间: |
|
| 查看次数: |
3520 次 |
| 最近记录: |