ios - 找不到具有传递依赖的开发 pod
问题描述
我正在开发一个 iOS 项目,在同一个 git 存储库中包含多个 pod,并且在使用development pods时我无法使用传递依赖项。
想象一下,我有以下存储库结构。
Root folder
- iOS # App folder
- modules
- ModuleA
- ModuleB
iOS 应用文件夹、模块 A 和模块 B 包含配置了 cocoapods 的 iOS 项目。它们都带有一个 Podfile 和一个配置为使用本地依赖项的 podspec。iOS 应用程序依赖于模块 A,模块 A 依赖于模块 B。但是,当我从 iOS 应用程序文件夹运行 pod install 时,它找不到 ModuleB 依赖项,并强制我手动将 ModuleB 依赖项声明为 iOS 应用程序 podfile 的一部分. 即使 ModuleA 依赖项已经在前 1 行声明并且 ModuleB 是 ModuleA 的依赖项。
这是配置 podfile 的方式:
- iOS Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
inhibit_all_warnings!
target 'iOS' do
pod 'ModuleA', :path => 'modules/ModuleA/'
# ModuleB pod should be imported as a transitive dependency of ModuleA
# but if I don't add it explicitly whenever I execute pod install,
# cocoapods fails because it can't find ModuleB.
pod 'ModuleB', :path => 'modules/ModuleB/'
target 'iOSTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
- ModuleA podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
inhibit_all_warnings!
target 'ModuleA' do
pod 'ModuleB', :path => '../ModuleB/'
target 'ModuleATests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
- 模块B podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
inhibit_all_warnings!
target 'ModuleB' do
target 'ModuleBTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
这是我们的 podspec 的配置方式:
- 模块A.podspec:
Pod::Spec.new do |s|
s.name = "ModuleA"
s.version = "1"
s.summary = "ModuleA"
s.homepage = "https://github.com/pedrovgs/iOSApp"
s.license = "MIT"
s.author = { "Pedro" => "pedro@pedro.com" }
# This path param is not available since cocoapods 16
s.source = { :path => '.' }
s.module_name = 'ModuleA'
s.requires_arc = true
s.source_files = '/**/*.swift'
s.ios.deployment_target = '12.0'
s.dependency 'ModuleB'
s.swift_version = '5.0'
end
- ModuleB.podspec:
Pod::Spec.new do |s|
s.name = "ModuleB"
s.version = "1"
s.summary = "ModuleB"
s.homepage = "https://github.com/pedrovgs/iOSApp"
s.license = "MIT"
s.author = { "Pedro" => "pedro@pedro.com" }
# This path param is not available since cocoapods 16
s.source = { :path => '.' }
s.module_name = 'ModuleB'
s.requires_arc = true
s.source_files = '/**/*.swift'
s.ios.deployment_target = '12.0'
s.swift_version = '5.0'
end
pod install
从 iOS 文件夹执行时,我面临的错误问题可以重现。ModuleB
除非我明确声明它在哪里,否则Cocoapods 无法从 iOS 项目中找到pod pod 'ModuleB', :path => 'modules/ModuleB/'
:. 如果你看一下 podspecs,这是有道理的。未s.source
正确配置,因为:path
不再支持 param。我可以配置一个 git 存储库或一个指向 zip 文件的 HTTP url,正如2019 年 GitHub 上的这条评论所建议的那样,但我想知道是否缺少任何配置。我发现的另一个选择迫使我将所有 podspecs 声明为根文件夹的一部分,就像Firebase iOS SDK 所做的那样。
这个问题迫使我在所有使用 ModuleA 的 pod 中将 ModuleB 指定为传递依赖项,除非我让 podspecs 配置正常工作。没有其他解决办法吗?我想将我的 pod 保存在不同的文件夹中,并将 podspec 文件放置在 Podfile 附近。我正在工作的存储库包含与不同平台相关的代码,因此我想避免将 podspecs 添加到 GitHub 问题中提到的根文件夹中。
关于 podspec。该命令pod lib lint --no-clean --allow-warnings
失败,因为它指定ModuleB
找不到 pod。这很明显,因为s.source
配置无效。Cocoapods 不会崩溃,它只会显示一个警告,但是当我们尝试验证 podspec 时会失败。
解决方案
推荐阅读
- c++ - const对象的容器?
- tensorflow - 使用flow_from_directory时如何获取混淆矩阵和ROC曲线?
- reactjs - 无法删除 useRef
设置反应离子时的值 - php - 用php从mysql列数据中分离值
- python - 运行相同网格搜索代码的不同超参数
- c - 我无法弄清楚为什么我的这部分代码没有运行,当它自己运行时就好了
- machine-learning - 处理丢失的数据而不泄露未来的观察结果
- python - 对齐 QScrollArea
- asp.net - Dotnet Blazor 在 Digital Ocean 上部署错误:无法检索有关进程或线程的指定信息
- python - how to create variable containing the age of another row inside a common id in Python 3.8?