简体   繁体   中英

Meaning of each Cocoapods build target

What is the purpose of each target in a Cocoapods workspace?

When I created a new CocoaPods library via "pod lib create Foo", I expected only two targets: One to build my library, and one to build my example.

But the resulting xcworkspace has a total of four targets:

  • Project Foo
    1. Target Foo_Tests
  • Project Pods
    1. Target Pods-Foo_Tests
    2. Target Pods-Foo_Tests-Foo
    3. Target Pods-Foo_Tests-Foo-Foo

What's the meaning of these targets?

(I chose no demo application, view-based testing, or testing frameworks.)

There are 2 project in your workspace one is yours and the other is cocoapods, and cocoapods adds new target for each pod which you add in your Podfile. For example, let's say this is your Podfile :

platform :ios, '7.0'

pod 'AFNetworking', '~> 2.5.4'
pod 'BPXLUUIDHandler'

you should see in your pod project's target list something like this :

在此处输入图片说明

but what is that mean?

Targets where cocoapods manage everything for each pod. For example if you choose AFNwtworking target in pod project, you must see something like this :

在此处输入图片说明

but for example how cocoapods know to add "Link binary with libraries" frameworks like above? Well, please check AFNetworking's podspec file for this :

 s.public_header_files = 'AFNetworking/*.h'
  s.source_files = 'AFNetworking/AFNetworking.h'

  s.subspec 'Serialization' do |ss|
    ss.source_files = 'AFNetworking/AFURL{Request,Response}Serialization.{h,m}'
    ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics'
    ss.osx.frameworks = 'CoreServices'
  end

  s.subspec 'Security' do |ss|
    ss.source_files = 'AFNetworking/AFSecurityPolicy.{h,m}'
    ss.frameworks = 'Security'
  end

  s.subspec 'Reachability' do |ss|
    ss.source_files = 'AFNetworking/AFNetworkReachabilityManager.{h,m}'
    ss.frameworks = 'SystemConfiguration'
  end

as you can see above this lines " ss.ios.frameworks " are describe what is going on there.

Hope everything is clear now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM