Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

ios - What does inherit! :search_paths do?

After looking at CocoaPods' own example (from 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

I don't see why inherit! :search_paths is necessary? All 3 targets, ShowsiOS, ShowsTV and ShowsTests have access to ShowsKit from their parent target.

The specific example for inherit! (from https://guides.cocoapods.org/syntax/podfile.html#inherit_bang) doesn't add any clarity

target 'App' do
  target 'AppTests' do
    inherit! :search_paths
  end
end

Can you help me understand what inherit! :search_paths is for?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The purpose behind behind inherit!, according to https://guides.cocoapods.org/syntax/podfile.html#inherit_bang (which I would agree is not very clear), is to provide one of 3 available modes:

  • :complete The target inherits all behaviour from the parent.
  • :none The target inherits none of the behaviour from the parent.
  • :search_paths The target inherits the search paths of the parent only.

In this question's example it is the :search_paths mode that is being expressed. The three different modes serve different roles when testing a Pod project.

Here is an additional link pertaining to Framework Search Paths in Xcode that helped clear some confusion for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...