Let’s start by reviewing common Git and Pod commands

  • Git Git
# initialization
git init                                            # to create
git clone /path/to/repository                       # check out
git config --global user.email "[email protected]"    # configuration email
git config --global user.name "Name"                Configure the user name

# operation
git add <file>                  Add file, A → B
git add .                       Add all files, A → B

git commit -m "Code Submission Information"      File submission, B → C
git commit --amend              *B → C

git push origin master          Master branch C → D
git pull                        Update the local repository to the latest changes, D → A
git fetch                       Fetch remote repository update, D → C

git log                         Check the submission record
git status                      # check the modification status
git diff                        # View detailed changes
git show                        # display the content of a submission

# undo
git reset <file>                A file index is rolled back to the last commit, C → B
git reset                       The index is rolled back to the last commit, C → B
git reset --hard                The index is rolled back to the last commit, C → B → A

git checkout                    # from index to workspace, B → A
git checkout -- files           Copy the file from index to workspace, B → A
git checkout HEAD -- files      C → A: Copy the file from local repository to workspace

# Branch correlation
git checkout -b branch_name         Create a branch named "branch_name" and switch to it
git checkout master                 Switch back to the main branch
git branch -d branch_name           # delete branch named branch_name
git push origin branch_name         Push branch to remote repository
git merge branch_name               # merge branch branch_name into current branch (e.g. Master)
git rebase                          # Derivatives, automatic linearization, D → A

# Conflict handling
git diff                                    # compare workspace with index
git diff HEAD                               # for workspace and the last commit
git diff <source_branch> <target_branch>    # Contrast differences
git add <filename>                          Add to indicate successful merge

# other
gitk                                Git with lights on
git config color.ui true            Git output in color
git config format.pretty oneline    Only one line is displayed for each submitted message
git add -i                          Add files to the staging area interactively
Copy the code
  • Pod common commands
Pod Repo push local private library xxx.PodSpecAdd the current index to the private index and synchronize it to the remote indexPod lib createCreate a git repository locally based on a POD template
pod lib lint		# POD local library validation
pod spec lint		# POD remote library validation
pod repo push 		Podspec file name: The command will add the POD index to the local index and then push it to the remote index

pod search		This command is used to search for available POD dependency libraries. The search result will show how to use this dependency library in pod
pod init		Create Podfile
pod install		The project's POD dependencies are pulled based on the version of the pod dependencies specified in the podfile.lock file. When the pod install command is first executed, the podfile.lock file is generated if no podfile.lock file exists, and both the xcWorkspace file and the Pods folder are generated. Switch to the project directory
pod update		This command will check the version of the POD dependency library in the podfile.lock file and update it to generate a new podfile.lock file
pod setup		When you install Cocoapod, you can use the pod setup command to initialize the pod environment. Is through in ` ~ /. Cocoapods/repos under create a directory, the directory is through public clonehttps://github.com/CocoaPods/Specs master per pod warehouse, in some enterprise development, You often have your own POD repositories, which you can simply add to the directory using the command on the next line:
pod repo add NAME URL[branch]	Use your own POD repository, there will be faster operation of the POD dependent library.

Copy the code

The complete steps to create a private library are as follows:

Create index libraries for private libraries

Two concepts need to be distinguished:

  1. Private library: This is where we actually put the component code
  2. Index library: a place where spec files are stored and used to index code. Index libraries are like Pointers. Private libraries are like objects. Pointer to the address where the object is located.

Add the created index library to the local Cocoapods repository

  1. Create a private library liszRepo to hold indexes

  2. Add your own remote index library locally

bogon:/ shaozhouli$ pod repo add liszRepo http://git.xxx-inc.com/lisz/liszRepo.git
Copy the code
  • If you run this command, a fatal: Authentication failed for error may occur. The solution is as follows:
Git config --list 2. 3. Run the pod repo add command again and enter the correct user name and passwordCopy the code
  • The cocoapods local repository path is as follows:
$ ~/.cocoapods/repos
Copy the code

Create a template

  • To create a template, run the following command:
$ pod lib create SYTool
Copy the code
  • Enter the prompt information as prompted

Four. Put our own code files into the specified directory

  1. Drag the Tool folder containing the code into Classes
  2. Drag the Tool directory under SYTool in your project

The local tripartite component has been made, and now it will be uploaded online

V. Upload the finished components to GitLab

  1. First create a SYTool project (attribution to liszRep, not yet established)
  2. Run the following command to upload the template file
2. Run the git remote add origin command to manage the remote repository: http://git.xxx-inc.com/lisz/SYTool.git 3. Git push -u origin master git push -u origin masterCopy the code

At this point, the local template has been uploaded to the repository

  1. Upload the code for the component because only the template file was uploaded in the previous step
// Add the workspace code to the staging area'initialize'$git push -u origin master $git push -u origin masterCopy the code

Vi. Change the information about the template file

Modify files with the. Podspec suffix, change:

  1. S. Summary: Short description displayed in POD Search
  2. S. sion: indicates the version number
  3. S. homepage: Change the page to git.xxx-inc.com/lisz where the component repository is created
  4. S.ource: Change to create component repository address git.xxx-inc.com/lisz/SYTool…

Verify the spec file

pod lib lint 
Copy the code

8. Branch the version

Git tag 0.1.0 Git pushCopy the code

9. Build relationships

The current podSpec synchronizes to the local private library and synchronizes the remote and local index libraries

pod repo push liszRepo SYTool.podspec
Copy the code

There may be a problem with this step:

Fatal: The remote repository cannot be read. Make sure you have the correct access rights and that the warehouse exists.

$ eval "$(ssh-agent -s)"
$ ssh-add
Copy the code

Git adds a public key to Github without Permission

Review the process of creating a private library as follows:

  1. Create local index library:
pod repo add QinzRepo https://gitee.com/Qinz_323/QinzRepo.git 
Copy the code
  1. Create a template:
 pod lib create QinzTool
Copy the code
  1. Enter the project and upload the template:
git remote add origin https://gitee.com/Qinz_323/Tool.git
git push -u origin master
Copy the code
  1. Upload code:
$ git add .
$ git commit  -m  'initialize'
$ git push -u origin master
Copy the code
  1. Verifying the Spec file
$ pod lib lint  --private
Copy the code
  1. Play tag
$git tag 0.1.0 $git pushCopy the code
  1. associated
$ pod repo push QinzRepo QinzTool.podspec
Copy the code

This step may cause the following errors:

Your configuration specified that the remote reference ‘refs/heads/master’ should be merged, but this reference was not obtained. The private index library is not initialized. The solution is as follows:

Other FAQ highlights:

  • Podspec files contain MRC file classes
s.source_files  = "MCFoundation/**/*.{h,m}"
s.requires_arc = false
s.requires_arc = "MCFoundation/CommonComponent/**/*.{h,m}"
# # directory, s.r equires_arc = [" MCFoundation/CommonComponent / * * / * ",
"MCFoundation/CommonComponent1/**/*",]Copy the code

Refer to the following article:

Creation of a private library for iOS componentized exploration

Common pod commands

Git common command description

Git common commands and Git Team usage guidelines

Git server setup and fix the ‘refs/heads/master’ problem in your configuration that specifies to merge remote references