看完CocoaPods的示例之后(来自https://guides.cocoapods.org/syntax/podfile.html#abstract_target)

# Note: There are no targets called "Shows" in any of this workspace's Xcode projects
abstract_target 'Shows' do
  pod 'ShowsKit'

  # The target ShowsiOS has its own copy of ShowsKit (inherited) + ShowWebAuth (added here)
  target 'ShowsiOS' do
    pod 'ShowWebAuth'
  end

  # The target ShowsTV has its own copy of ShowsKit (inherited) + ShowTVAuth (added here)
  target 'ShowsTV' do
    pod 'ShowTVAuth'
  end

  # Our tests target has its own copy of
  # our testing frameworks, and has access
  # to ShowsKit as well because it is
  # a child of the abstract target 'Shows'

  target 'ShowsTests' do
    inherit! :search_paths
    pod 'Specta'
    pod 'Expecta'
  end
end

我看不出为什么需要inherit! :search_pathsShowsiOSShowsTVShowsTests这3个目标都可以从其父目标访问ShowsKit
inherit!的特定示例(来自https://guides.cocoapods.org/syntax/podfile.html#inherit_bang)没有增加任何清晰度
target 'App' do
  target 'AppTests' do
    inherit! :search_paths
  end
end

您能帮我了解inherit! :search_paths是什么意思吗?

最佳答案

根据https://guides.cocoapods.org/syntax/podfile.html#inherit_banginherit!背后的目的
(我同意不是很清楚)是提供3种可用模式之一:

  • :complete目标从父级继承所有行为。
  • :none目标不会从父级继承任何行为。
  • :search_paths目标仅继承父级的搜索路径。

  • 在此问题的示例中,正在表达的是:search_paths模式。测试Pod项目时,三种不同的模式扮演不同的角色。

    与Xcode中的框架搜索路径有关的Here is an additional link帮助我消除了一些困惑。

    07-28 12:08