Project on-line, finally have time to study some tripartite things, in their own drill horn, unconsciously fell into the mistakes. In the process of project practice, I also learned a lot from the boss and felt that I had some oil in my stomach, but when I saw those great open source works on GitHub, I could not help feeling inferior. Although I entered the line for a year, I was highly respected by my boss and gave a mission to lead my apprentices. I was abused and advanced in communication, and went forward with bitter and warm heart. Although he was a teacher, but from qualified teachers, really there is a gap, at least teammates give feedback is: “poor expression ability, always live in their own ideas.” Suddenly I thought of a little Yue yue saying: “Although I work very tired every day, but I earn less!” “I say,” You work so hard every day, put up with so much loneliness and pain, but I don’t see how wonderful you are!” I still know too little. All right, here’s the business:

In the process of introducing the third-party SDK into the project, various imported library files, various configuration changes, especially when updating the SDK, it was really a big deal. I often see people using automatic third-party library management tool Cocoapods on the Internet. I have not dared to try it in the original project, but I have been researching it recently. It really gives me a bright feeling in using it, but I have encountered many problems in the process.

Installation process steps here is not much to talk about, online casually search……


  • When importing a file using the pod command, the terminal will prompt:
    Analyzing dependencies Downloading dependencies Installing...... Generating Pods project [!]  From now on use `ProjectName.xcworkspace`.Copy the code

If you use the CocoaPods organization to manage the third-party library, you can only open it through projectname.xcworkspace. If you open the original project, it will compile an error. After executing the pod command, files such as projectName.xcworkspace, Podfile.lock, and Pods are generated in the project.






CocoaPods works

The work of CocoaPods is organized primarily through projectName.xcworkspace, and when you open the projectname.xcworkspace file, you find that Xcode has an extra Pods project.

  1. Library file introduction and configuration:

    Library files are introduced primarily in the Pods projectPods-ProjectName-frameworks.shAt each build, the script will help you package all the pre-imported tripartite library files into the projectName. a static library file, which will be placed in the Framework folder of our original Xcode project for use by the project.
  2. Resource files: Resource files are handled by the Pods-projectname-resources. sh script in the Pods project. This script will help you copy the Resource files of all three libraries to the target directory each time you compile.

  3. Dependency parameter Settings: Each library file in the Pods project has a corresponding sdkname.xcconfig. At compile time, CocoaPods uses these files to set all dependency parameters. After compile, two configuration files are generated in the Pods folder of the main project. Pods – ProjectName. Debug. Xcconfig, Pods – ProjectName. The xcconfig.

Problems encountered in use:


1. The configuration speed of the install and update commands is incorrect

After pod Install or Pod Update is entered, CocoaPods first matches the local spec library and then downloads it only after confirming that the spec library doesn’t need to be updated. Instead, skip the spec repository and update the match using the following two commands.

pod update --verbose --no-repo-update
pod install --verbose --no-repo-updateCopy the code

Some friends say no--verbose, in fact, add--verbose–no-repo-update (); –no-repo-update (); –no-repo-update ()

pod install --no-repo-update --verbose // Do not update, and print detailed process informationCopy the code
2. The dependency * * * * is not used in any concrete target.

[!] The dependency UMengAnalytics-NO-IDFA is not used in any concrete target. This tip is due to a problem with writing Podfile files after cocoapods has been updated to 1.0, before 1.0:

   platform :ios
   pod 'UMengAnalytics - NO - IDFA pod' 'MBProgressHUD', '~ > 0.9.2' pod 'FMDB' pod 'SDWebImage', '~ > 3.7.3' pod 'IQKeyboardManager', '~ > 3.2.4' pod 'MJRefresh', '~ > 2.3.2' pod 'MJExtension', '~ > 0.2.0'Copy the code

After 1.0:

   platform :ios, '7.0'target' ProjectName 'do #ProjectName ProjectName
   pod 'MBProgressHUD'.'~ > 0.9.2'
   pod 'FMDB'
   pod 'SDWebImage'.'~ > 3.7.3'
   pod 'IQKeyboardManager'.'~ > 3.2.4'
   pod 'MJRefresh'.'- >' 2.3.2
   pod 'MJExtension'.'~ > 0.2.0'
   pod 'UMengAnalytics - NO - IDFA' endCopy the code
3. Unable to satisfy the following requirements: – SDWebImage (- > 3.8) required by Podfile

[!] Unable to satisfy the following requirements: -sdwebImage (~> 3.8) required by Podfile

4. Header files cannot automatically complete after using CocoaPods

It is convenient to use CocoaPods to manage tripartite libraries, but there is a small problem. When importing files from CocoaPods, you cannot automatically complete the file and need to manually copy the file name. Add ${SRCROOT} or $(PODS_ROOT) to the Target -> Build Settings, User Header Search Paths entry and select Recursive to Search for it.

5. Remove the CocoaPods third-party library configuration file from the project

If you don’t need CocoaPods libraries anymore after configuring them, you can remove the specified libraries as follows:

  • Delete the Podfile, Podfile.lock, and Pods folders from the project folder.
  • Delete the xcWorkspace file;
  • Open the xcodeProj file and remove the libPods. a and Pods.xcconfig references from the project;
  • Open Build Phases and delete Check Pods manifest.Lock and Copy Pods Resources.
  • Pod install again