Installation and use of Cocoa pods

Source: Internet
Author: User

principle

Cocoapods principle, it is to put all dependent libraries into another named Pods project, and then let the main project depends on the pods project, so that the source management work from the main project moved to the PODS project

    • 1, Pods project will eventually compile into a file named Libpods.a, the main project only need to rely on this. a file.
    • 2. For resource files, Cocoapods provides a bash script called pods-resources.sh, which executes every time the project is compiled and copies the various resource files from the third-party library to the target directory.
    • 3, cocoapods through a file called Pods.xcconfig to set all the dependencies and parameters at compile time.
      • Attention
      • About. Gitignore
        After you perform the pod install, Cocoapods will generate a file named Podfile.lock, except for Podfile, and you should not add the file to the. Gitignore. Because Podfile.lock locks the version of the current dependent library, if the pod install does not change the version more than once, the pod update will change podfile.lock. When many people collaborate, you can prevent third-party libraries from being upgraded with inconsistent versions of your third-party libraries.
Common directives
1.pod Install --no-repo-update (disable index update operation) pod update --no-repo-update2. Pod serach:' pod search afnetworking '3. Pod outdated:' Check for updates to each third-party library '4. Pod init: Automatically generates a podfile file and initializes 5. Vim edit mode, input i enter edit, press ESC to exit edit, press:, enter WQ back to console
Problems that you may encounter

(1) Using Cocoapods to import a third-party class library does not have code hints?
Workaround: Select Target, Build Settings menu, find \ "User Header Search paths\" setting entry, add a value of "${srcroot}" and select \ "Recursive\"

(2) The following warning appears
[!] Your Podfile has had smart quotessanitised. To avoid issues on the future, you should not use TextEdit forediting it. If you is not using the TextEdit, you should turn off smart quotes Inyour editor of choice.
Workaround: Do not use text editing to edit podfile, use Xcode to edit, or use the terminal to tap commands to edit.

(3) After the pod install or pod Update command is executed, updating local specsrepositories is stuck
Workaround: Pod Install is wall, replace with new command pod install--verbose--no-repo-update

(4) Project run times error: Thefile "pods.xcconfig" couldn ' t be opened because there is no such file.
WORKAROUND: Pod update is available.

1. Upgrade the Gem sudo gem firstUpdate --system2.Switch cocoapods data source "First delete, then add, view" gem sources--remove https://rubygems.org/Gem sources-a https://ruby.taobao.org/gem Sources-L3.Installing the Cocoapods sudo gemInstallCocoapods or (e.g.10.11System) sudo gemInstall-N/usr/Local/binCocoapods4.Switch Podspec file hosting address from GitHub to domestic oschina "first delete, then add, then Update" pod repo removeMasterPod RepoAdd MasterHttps://gitcafe.com/akuandev/Specs.git pod RepoUpdate5.Set up pod warehouse pod setup6.Test "If there is a version number, the installation is successful" pod--version7.Use Cocoapods to install third-party frameworks onEnter the. Xcodeproj Sibling folder for the project to which you want to install the framework GenevaCreate a new file in this folder PodfileGenevaIn the file, tell cocoapods the framework information that needs to be installed a. platform supported by the Framework B. applicable iOS versionC. The name of the frameworkD. The version of the framework8.Installing PodsInstall --no-repo-updatePodUpdate --no-repo-update9.Description Platform:ios,' 8.0 'Used to set the minimum iOS version of the pod supported by all third-party libraries' Sdwebimage ',' ~>2.6 'Set the frame name and version number format to refer to the latest version,------------standard format in pod initRule for version number:' >1.0 'Can install any higher than1.0Version of' >=1.0 'Can install any above or equal1.0Version of' <1.0 'Any less than1.0Version of' <=1.0 'Any less than or equal to1.0Version of' ~>0.1 'Any above or equal to0.1version, but does not contain a higher1.0Version of' ~>0 'Any version, the equivalent of a non-specified version, by default the latest version number.Using PodsInstallcommand to install the framework after the approximate process: onAnalysis dependencies: This step analyzes podfile to see dependencies between different class libraries. If more than one class library relies on the same class library, but relies on different versions, Cocoapods automatically sets a compatible version. GenevaDownload dependency: Download the specified version of the class library to a local project, based on the results of the analysis dependency.GenevaBuild a Pods project: Create a Pods project that is designed to compile and manage third-party frameworks, Cocoapods will add the required frameworks, libraries, and so on to the project, and configure them accordingly.GenevaConsolidate PODS projects: integrate pods and projects into one workspace, and set up file links. One. Note the Apple system upgrade OS X EL Capitan after change to $sudo gemInstall-N/usr/Local/binCocoapods, to precede the instruction with sudo, will alert you to enter the password, and then install
Cocoapods directive
Usage: Pod COMMAND CocoaPods, the Cocoa library package Manager.commands: +CacheManipulate the CocoaPodsCache+ deintegrate Deintegrate CocoaPods fromYourProject. + env Display pod environment + init Generate a podfile forThe Current Directory. +Install       Install ProjectDependencies toPodfile.Lock versions+ IPC inter-process communication + lib Develop pods +List          ListPods + OutdatedShowOutdatedProjectDependencies + PluginsShowAvailable CocoaPods plugins + repo Manage spec-repositories +Search        Search  forPods. + Setup Setup the CocoaPods environment + spec Manage pod specs + trunk Interact withThe CocoaPods API (e.g. PublishingNewSpecs) + Try try a pod! +Update        UpdateOutdatedProjectDependencies and Create NewPodfile.LockOptions:--silent Show Nothing    --version Show The version of the tool    --verbose Show more debugging information    --no-ansi Show output without ANSI codes    --help Show help Banner of specified command

Installation and use of Cocoa pods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.