CocoaPods command and use

CocoaPods command

pod init run this command in the root directory of the new project, the new podfile file for the current project.
project dependencies pod install download and configure podfile defined in (not including project dependencies have been downloaded and configured). (New podfile.lock file) and each dependency version information is recorded in podfile.lock file. New .xcworkspace file for the project.
pod outdated lists than podfile.lock file recorded version to the new project.
pod update [dependent on the project name] will depend on an update to the latest version directly pod udate put all the dependencies are updated to the latest version.

CocoaPods use

Use CocoaPods project than the project without the use of the four files: files are podfile, podfile.lock file, .xcworkspace Pods file and a folder.
podfile file for each target defined projects depend on project (running on different iOS version) needed. podfile.lock file is used to record the current version of each project depend on the project, to ensure that the version information of the project will not be changed. The relationship between all project files .xcworkspace file as the startup file using CocoaPods after project records. Pods folder is dependent on local projects stored.
The key to using CocoaPods in the project is to create a new profile files. With the profile file, and the rest use a command can be done automatically.

1, the new project and use CocoaPods

Run under the new project root directory of the command pod init command. Automatically generates a profile file in the root directory of the project. This completes the use CocoaPods preparations.
The next step is to open the profile file, define dependencies, and runs pod install command will generate the project files and use podfile.lock .xcworkspace documents described above.

2, existing projects using CocoaPods

Manual new item in the root profile files that define its dependencies, then run pod install, will generate the above three documents.

Precautions

1, the initial use

CocoaPods initial use of pod install command, CocoaPods itself automatically initialized. Initialization does in fact depend on the entire library on github downloaded to the local path / users / username /.cocoapods/repos/master folder. But the country is not enough, the wall, that is, would have been stuck in the CocoaPods set up master repo words did not move, or after a long time to give you an error saying unable to install bla bla bla ... Then you can on the github Download (address: https: //github.com/CocoaPods/Specs), and then download the content to copy itself to this path like (or let other people have to spend CocoaPods the airdrop over faster than downloading, after all A big files ..). FIG next master file structure:


The figure above, Specs whole is dependent libraries.
2, version control
podfile.lock file version control should always be involved.

Basic language file format profile

1, the basic format

Define the dependencies for a target format
most simple example:
target 'the MyApp' do
POD 'AFNetworking', '~> 3.0'
POD 'FBSDKCoreKit', '~> 4.9'
end
. 1
2
. 3
. 4
Inheritance large do - between the end defined in dependent projects
target 'the MyApp' do
POD 'GoogleAnalytics', '~> 3.1'
target 'MyAppTests' do
the inherit:! search_paths
POD 'OCMock', '~> 2.0.1'
End
End
. 1
2
. 3
. 4
. 5
. 6
. 7
above MyAppTests also depends GoogleAnalytics.

Define multiple target share of dependent projects using abstract_target
# There are NO Targets Called "Shows" in the any Xcode the Projects
abstract_target 'Shows' do
POD 'ShowsKit'
POD 'Fabric'

# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end

Has own Copy of ITS # ShowsKit + ShowTVAuth
target 'ShowsTV' do
POD 'ShowTVAuth'
End
End
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
The above Shows just identified, there is no such target. But other target between its do-end defined by the dependent abstract_target share as defined above.

Define project dependent projects all target are used
directly without any modification defines it as follows:
POD 'ShowsKit'
POD 'Fabric'

# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end

Has own Copy of ITS # ShowsKit + ShowTVAuth
target 'ShowsTV' do
POD 'ShowTVAuth'
End
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
2, that specifies the version project
- to specify a revision:
POD 'item name', ' The version number '
such as:
POD' Objection ',' 0.9 '

Version range given
symbol>,> =, <, <= can be used,
such as:
'> 0.1'
symbol ~> Use the following examples, see:
'~> 0.1.2'
indicates a range of> = 0.1.2 && <0.2
' ~> 0.1 '
indicates a range of> = 0.1 && of <1
3 to add local project as dependent
as:
POD' Alamofire ',: path =>' ~ / Documents / Alamofire '

All the above examples from the official website.
---------------------
Author: ohyeahhhh
Source: CSDN
Original: https: //blog.csdn.net/ohyeahhhh/article/details/51878549
Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/itgezhu/p/11087580.html