问题描述
我目前正在开发一个 iOS SDK,使用 Cocoapods 来管理部署,使用 jazzy 来生成文档。我最近在一个子规范中添加了对 Google ads v8 的依赖项,并在另一个子规范中添加了对 Google ads v7 的另一个依赖项,如下所示:
s.subspec 'Admob' do |admob|
admob.source_files = 'MyLib/Classes/admob/**/*.{swift,h,m}'
admob.dependency 'MyLib/Core'
admob.dependency 'Google-Mobile-Ads-SDK','~> 8.0'
admob.xcconfig = { 'OTHER_SWIFT_FLAGS' => '$(inherited) -D SDK_ADMOB' }
end
s.subspec 'Admob7' do |admob|
admob.source_files = 'MyLib/Classes/admob7/**/*.{swift,'~> 7.0'
admob.xcconfig = { 'OTHER_SWIFT_FLAGS' => '$(inherited) -D SDK_ADMOB' }
admob.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
admob.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
end
documentation: "*.md"
xcodebuild_arguments: -scheme,Tests
module: MyLib
sdk: iphone
source_directory: MyLib
podspec: MyLib.podspec
theme: fullwidth
readme: USERGUIDE.md
当我运行 bundle exec jazzy
时,我遇到了冲突,因为它希望您同时使用我的所有子规格:
Using config file /Users/***/***/.jazzy.yaml
Analyzing dependencies
bundler: Failed to load command: jazzy (/usr/local/lib/ruby/gems/2.7.0/bin/jazzy)
Pod::informative: [!] CocoaPods Could not find compatible versions for pod "Google-Mobile-Ads-SDK":
In Podfile:
MyLib/Admob (from `/Users/***/***`) was resolved to 2.8.0,which depends on
Google-Mobile-Ads-SDK (~> 8.0)
MyLib/Admob7 (from `/Users/***/***`) was resolved to 2.8.0,which depends on
Google-Mobile-Ads-SDK (~> 7.0)
有人能告诉我是否可以从我的文档生成中排除一个或几个子规范吗?
解决方法
好的,Jazzy 中似乎没有解决此问题的选项。我最终写了这个脚本:
### Removing admob7 subspec before generating doc is necessary.
# add a new line to the podspec file to remove it after awk treatment
echo "" >> MyLib.podspec
# create the jazzy podspec
awk '!/Admob7/' RS=s.subspec ORS=s.subspec MyLib.podspec > MyLib.jazzy.podspec
# clean the last line which contains an awk artifact
sed -i '' -e '$ d' MyLib.jazzy.podspec
# remove the last line we added before
sed -i '' -e '$ d' MyLib.podspec
bundle exec jazzy
并更改了 jazzy yml 配置文件中的 podspec
documentation: "*.md"
xcodebuild_arguments: -scheme,Tests
module: MyLib
sdk: iphone
source_directory: MyLib
podspec: MyLib.jazzy.podspec
theme: fullwidth
readme: USERGUIDE.md