Part ONE: the process of making private library

1. Create an index library before setting up a private library

  • First check the current computer’s index library:

➜ pod repo

2. If no remote index library exists, create an index library and associate it with the local database

If github does not already have an index library, create a new library on Github that will hold the podspec files of the private library, so the best name is xxxSpec to distinguish the purpose of the library. Create a local index library and associate it with the remote index library you just created. The remote index library is * empty! Empty! Empty! * But there must be a master branch, so you can add a readme file.

The new command

1. The LIST of the REPO local resource libraries is displayed

➜ Pod repo/Pod repo List

2. Increase the repo

➜ pod repo add XXXSpec Github address of the remote index library that you just created

3. Remove the repo

➜ pod repo remove XXXSpec

============ [operation] ==============

➜ Pod Repo add mySpec github.com/xxxx/TestSp… Cloning spec repo mySpec from http://github.com/xxxx/TestSpec.git ➜ pod repo

Part two: the process of making private library

1. Create local private libraries (codebase)

// Use CocoaPods formatting to create (custom remote library name: LibName) ➜ pod lib create LibName

2. Local authentication

A. There are no other dependent libraries in the private library

➜ pod lib Lint –allow-warnings ➜ pod lib lint qycqrcode. podspec –allow-warnings

B. If a private library has a dependent private library or a third-party library, add the source IP address

➜ pod lib lint –allow-warnings –sources=’github.com/xxxx/TestSp… ‘// full version ➜ pod lib lint qyccommon. podspec –allow-warnings –sources=’github.com/xxxx/TestSp… ‘

3. Commit private library code + tag(script operation)

A. Modify the PodSpec as required

Manually create a remote private library on Github (configure libname.podSpec)

Have s.homepage, s.source remote library addresses (s.homepage does not contain the. Git suffix)

B. Associate the local code with the remote POD library

➜ CD Local code file path

Git file ➜ git init

// README creates the file ➜ touch readme.md

➜ git add readme.md

➜ git commit -m “Initial commit”

➜ git branch -m master

➜ git remote add Origin github.com/xxxx/TestSp…

➜ git push -u origin master

C. Generate a script file and store it in a folder. The terminal runs the script

Execute the script in the same directory as the project file (_Pods.xcodeProj) (named publish

➜ sh publish. Sh

============= The script code is as follows: =============

#! /usr/bin/env bash

#Config Color

RED=’\033[0;31m’

GREEN=’\033[0;32m’

NC=’\033[0m’ # No Color

#const

Source1=github.com/CocoaPods/S…

commitText=””

tag=””

result=find ./ -maxdepth 1 -type f -name "*.podspec"

SpecName=${result}

# pull code

pull() {

Echo -e "${GREEN}\n ${NC}⏰⏰⏰" Then echo -e "${GREEN}pull code success ${NC}🚀🚀🚀" else echo -e "${RED}pull code failure, please manually resolve the conflict ${NC}🌧🌧🌧" exit 1 fiCopy the code

}

# Replace podSpec’s Tag

updatePodspec() {

Echo -e "${GREEN}\n Modify s.v ersion = ${tag} ${} NC ⏰ ⏰ ⏰ "sed -" 's/I "s.v ersion [[: space:]] * = [[: space:]] * \' [0-9 a zA - Z.] * \ '"/" s.v ersion = \'${tag}\'"/g ${SpecName}Copy the code

}

# local validation Lib

localVerifyLib(){

Echo -e "${GREEN}\n: pod lib lint ${NC}⏰⏰⏰" if! pod lib lint --skip-import-validation --allow-warnings --use-libraries --sources="${source1}"; Then echo -e "${RED} ${NC}🌧🌧🌧"; exit 1; Fi echo -e "${GREEN} Verification successful ${NC}🚀🚀🚀"Copy the code

}

#push code, tag

pushAndTag(){

${NC}⏰⏰⏰" git add.if! Git commit -m ${commitText} then echo -e "${RED} ${NC}🌧🌧🌧" exit 1 fi if! Git push then echo -e "${RED}git push failed ${NC}🌧🌧🌧" exit 1 fi echo -e "${GREEN} Submit code successfully ${NC}🚀🚀🚀" echo -e ${GREEN}\n $${NC}⏰⏰⏰" if git Tag${Tag} then git push --tags echo -e "${GREEN} 🚀 milk "else echo -e "${RED} failed to Tag ${NC}🌧🌧🌧" exit 1 fiCopy the code

}

# remote validation

remoteVerifyLib(){

Echo -e "${GREEN}\n: start remote validation: pod spec lint ${NC}⏰⏰⏰" if! pod spec lint --skip-import-validation --allow-warnings --use-libraries --sources="${source1}"; Then echo -e "${RED} ${NC}🌧🌧🌧"; exit 1; Fi echo -e "${GREEN} Verification successful ${NC}🚀🚀🚀"Copy the code

}

# libraries

publishLib(){

Echo - e "${GREEN} \ n step 6: version ready to release ${tag} ${} NC ⏰ ⏰ ⏰" if! pod trunk push ${SpecName} --allow-warnings; Then echo -e "${RED} failed to release ${NC}🌧🌧🌧"; exit 1; Fi echo -e "${GREEN} release ${tag} successful ${NC}🚀🚀🚀"Copy the code

}

# publish binary

publishBinary(){

Echo - e "${GREEN} \ n step 7: binary version ready to release ${tag} ${} NC ⏰ ⏰ ⏰" echo - e released "${GREEN} ${tag} the binary version successful ${} NC 🚀 🚀 🚀"Copy the code

}

Publish (){# echo -e “GREEN :{NC}” read a commitText=${a}

# echo - e "${GREEN} enter the tag: ${} NC" read the tag b = ${b} # if [-z "$commitText"]; Then the echo - e "${RED} ${} NC submitted content cannot be empty 🌧 🌧 🌧" exit 1 fi if [-z "$tag"]; ${NC}🌧🌧🌧" exit 1 fi if [-z "$SpecName"]; ${NC}🌧🌧🌧" exit 1 fi # pull # updatePodspec # localVerifyLib # pushAndTag # remoteVerifyLib # publishLib # publishBinaryCopy the code

} publish