2

我目前正在开发一个 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,h,m}'
    admob.dependency 'MyLib/Core'
    admob.dependency 'Google-Mobile-Ads-SDK', '~> 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

一切正常,除非我想用 Jazzy 生成文档。这是我的conf:

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)

有人可以告诉我是否可以从我的文档生成中排除一个或多个子规范?

4

1 回答 1

1

好的,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
于 2021-08-06T07:15:03.077 回答