ios - 如何在同一个颤振项目中将第三方/本地框架与颤振依赖项一起添加
问题描述
我正在开发颤振项目,我需要将颤振代码与本机目标 c 框架(本地框架)集成。
当我不使用任何颤振依赖项时,它工作正常,但是当我添加任何颤振依赖项时,例如 path_provider 或 image_cropper 等,当时应用程序显示错误,即
1./Users//Desktop///ios/Runner/GeneratedPluginRegistrant.m:6:9: 'image_cropper/ImageCropperPlugin.h' 文件未找到。
我认为这个问题是因为 podfile 配置,因为:
当我没有使用“use_frameworks!”时 这在 pod 文件中,然后我在颤振中使用的所有依赖项都可以在 .a 格式(静态库)以及我的本地框架/sdk 中看到,但是当我使用“use_frameworks!”时 pod 所有库中的声明以及我的本地 SDK(框架)都以 .framework 格式出现。
我希望颤振库/依赖项采用 .a 格式,我的框架采用 .framework 格式。
我正在使用的 podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
use_frameworks!
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def applibs
pod 'ThirdPartySDK-Debug', :configuration => ['Debug'], :path => 'Generated_Key_IOS_SDK/Debug/ThirdPartySDK-Debug.podspec'
pod 'ThirdPartySDK-Release', :configuration => ['Release'], :path => 'Generated_Key_IOS_SDK/Release/ThirdPartySDK-Release.podspec'
end
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
workspace 'Runner.xcworkspace'
project 'Runner.xcodeproj'
applibs
# 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/Runner.xcconfig')
if generated_xcode_build_settings.empty?
puts "Runner.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
我希望颤振库/依赖项采用 .a 格式,我的框架采用 .framework 格式。
解决方案
推荐阅读
- python - 我们如何杀死 python 中 subprocess.call() 函数产生的进程?
- python - 在 ajax 调用中保护 django 中的 json 端点
- rust - 将附加状态传递给 rust `hyper::service::service_fn`
- python - 是否可以一次调用多个不同的连接?
- ruby-on-rails - 我无法安装 gems:无法从 https://rubygems.org/ 下载数据 - 超时
- excel - SSIS 2017 循环遍历 Excel 文件并从脚本任务中获取文件名
- c# - 有没有办法在 web api c# 的构造函数中读取 cookie
- c++ - C++ E0137 表达式必须是可修改的左值
- r - R中的街道地址清洁
- ios - 是否可以在详细视图中编辑 SwiftUI 列表元素?