How does CocoaPods work

后端 未结 2 738
小蘑菇
小蘑菇 2020-11-27 21:34

I used CocoaPods for some of my projects. It\'s cool and easy to keep updated with my dependencies/open source frameworks.

But I have some doubts regarding the inner

相关标签:
2条回答
  • 2020-11-27 22:07

    CocoaPods is a centralised dependency management. It operates by Podfile to read a dependency and a version. Pod project will be created in a workspace. CocoaPods implements Implicitly dependency[About] approach:

    • Source code
    • Closed code[Example]

    On the client side you have a Podfile. The core of Podfile is a pod:

    • name
    • version - Semantic versioning

    When Podfile is read (during pod install or pod update) by Cocoapods the graph of implicit and explicit dependencies is created. After that the manager should find each source into a .podspec which is usually hosted into some host. That is why Cocoapods is centralised. A framework's developer is responsible for creating this file and supporting it. .podspec describes a meta-information about the framework, like dependencies, subspecs, etc. The main part of it is source which tells to Cocoapods where source is hosted and this sources will be downloaded into a Pod project. Cocoapods uses workspace to automate the build process and manage implicit dependencies. Cocoapods setup all necessary info into your consumer project(like Search pats, etc). When you build the consumer project Xcode pull pods and assemble all together.

    [Local podspec]
    [CocoaPods version]
    [CocoaPods vs Carthage]

    0 讨论(0)
  • 2020-11-27 22:11

    CocoaPods does a whole lot behind the scenes to make everything you're talking about work. On a relatively high level the actual 'Pods' are managed in a repo that lives on Github here. This is where 3rd party library vendors submit their 'Pods' to work with CocoaPods. You'll notice that if you search for a Pod using the command line tool with pod search AFNetworking you will see all the available Pods matching your search term.

    As far as Github vs other sites goes even though the repository full of CocoaPods specifications lives on Github, CocoaPods itself uses just plain old Git to pull down the source from the given repository. Because of this you could make specs from any git repo hosted on any site. We also support svn, mercurial and just plain old http(s). If you're interested in how the specs work overall you can look at some in the specs repo you can open them from ~/.cocoapods/repos/master on your local machine or edit one directly with pod spec edit AFNetworking from the command line.

    0 讨论(0)
提交回复
热议问题