Cocoapods is a collection of thousands of third-party open Source Library development tools, can greatly improve the team project development efficiency, reduce time costs.
So take a look at cocoapods. The use of this tool is reflected in the project.
We immediately use the asihttprequest third-party open source framework to explain how to use the Cocoapods tool in our projects to quickly integrate third-party open source frameworks .
First, create an empty application engineering emptysampleunder the iOS platform.
Then, enter the new project directory in the terminal,
Results.
Under the new project root directory, create a new Podfile file with the VI command . Note that you do not have to add the file suffix name )
VI podfile
Then we'll edit the content in the podfile file as
' 7.0 ' 'asihttprequest'~> 1.8.2'
After saving the file, we can see that a podfile file is already in the root of the newly-created Emptysample project.
Next, use the pod Update command in the terminal to update our project, and when the following appears, the project is updated according to the Podfile file. ( note that because the third-party open source framework
need a network download, so there will be a brief stagnation in the middle )
Update all podsanalyzing dependenciesdownloading dependenciesinstalling asihttprequest (1.8. 2 ) Installing reachability (3.1. 1 ) generating Pods projectintegrating client project[!] From "On" Use ' emptysample.xcworkspace '.
So now we need to pay attention to two.
- The pod Update command can only be used when the third-party tool has been installed in our Mac OS environment cocoapods;
- pod Update The command can only be used if the Podfile file is already contained in the terminal's current directory;
- pod Update the function of the command is to update the current project directory and the engineering files in the project catalog according to the contents of the Podfile file . (***.xcodeproj)
When the project is successfully updated, we can open the project again without opening the ***.xcodeproj file, but open the ***.xcworkspace.
Next, let's take a look at how to configure the Cocoapods tool in your environment, as well as engineering updates in projects that already use Cocoapods.