Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - How Cocoapods compile pods?

I have a xcworkspace built with cocoapods (pod install). The things it that I can't figure out how xCode knows that when I build MyProject it must also build the Pods project?

Hypothesis:

In MyProject main target in build phase "Link Binary with Libraries" section I can see "Pods_MyProject.framework" which refers to the .framework build by Pods ( the project ) Pods-MyProject target (is it correct?). This target has in his "Target Dependencies" all the pods.

But I still don't understand two things

  1. How Xcode knows that when I build MyProject it must first build Pods-MyProject ?? (There is nothing in MyProject main target "Target Dependencies" section)

Here is the build phases tab of "MyProject" (its real name is "clicktube"):

enter image description here

  1. How the "Pods_MyProject.framework" contains all the pods while its "Link Binary with Libraries" section is almost empty?

The Pods-MyProject "Link with Libraries" section:

enter image description here

like image 658
NathanVss Avatar asked Sep 19 '26 13:09

NathanVss


1 Answers

Here is the interesting thing:

https://developer.apple.com/library/content/featuredarticles/XcodeConcepts/Concept-Workspace.html#//apple_ref/doc/uid/TP40009328-CH7-SW1

Xcode examines the files in the build directory to discover implicit dependencies. For example, if one project included in a workspace builds a library that is linked against by another project in the same workspace, Xcode automatically builds the library before building the other project, even if the build configuration does not make this dependency explicit. You can override such implicit dependencies with explicit build settings if necessary. For explicit dependencies, you must create project references.

There are two types of dependencies: explicit and implicit. You specify the explicit ones in the "Target dependencies". The implicit dependencies are discovered by XCode by looking at the "Link binary with libraries" and then it decides the order in which the projects will be built.

How the "Pods_MyProject.framework" contains all the pods while its "Link Binary with Libraries" section is almost empty ?

If you look into the Pods.xcodeproj there is a target for each framework that you 'installed' via podfile. Then there is the Pods_MyProject.framework target which has an explicit dependency on all these frameworks.

like image 60
vbgd Avatar answered Sep 21 '26 16:09

vbgd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!