Index library repo
Index file (.podspec file)
1. Before building a private library, you must first create an index library
1) First check the index library of the current computer
under the repo
2) Create a new library on gitlab. This library is used to save the podspec file of the private library, so we generally name it xxxSpec to distinguish the role of this library.
3) Create a local index library, and then associate it with the remote index library just created. Pay attention! ! ! The remote index library at this time is empty! empty! empty! But there must be a master branch, so you can add a readme file.
Two methods: 01-https method; 02-ssh method (ssh method requires SSH to be configured in advance )
pod repo add local index library name git address of remote index library
例如:pod repo add Pinnet Spec http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git
4) Check whether the installation is successful
cd to the new index library
cd ~/.cocoapods/repos/ Pinnet Spec
Verify index file repository
pod repo lint .
Delete local repo
pod repo remove [index library name]
Update the cache information of the local Pod index library
pod repo update --verbose
2. Create a local private library (component library)
1) Create a local private library
cd to the local private library folder to be created and execute
pod lib create [component library name]
The name of the component library here must be consistent with the name created in the remote warehouse
For example: pod lib create PinnetHeaderSegment
Error [!] /usr/bin/git clone https://github.com/CocoaPods/pod-template.git xxx
Cloning into 'xxx'...
fatal: unable to access 'https://github.com/CocoaPods/pod-template.git/': error:02FFF036:system library:func(4095):Connection reset by peer
or
fatal: unable to access 'https://github.com/CocoaPods/pod-template.git/': SSL certificate problem: unable to get local issuer certificate
Remove proxy
git config --global http.proxy
git config --global --unset http.proxy
2) Refer to the figure below for parameter configuration
3) After the configuration is completed, a HeaderSegmentView-Example project will be automatically opened. The hierarchy is as shown below
4) Delete the ReplaceMe.m file under the Classes folder and replace it with the code of the component library
5) Install the pod library
cd to the Example folder and execute
pod install
wait for some time
6) Modify the xxx.podspec configuration file
Ps:
(A) s.homepage needs to be modified to the homepage address of the remote private library, not the address of the private index library! ! !
(B) s.source needs to be modified to the git address of the remote private library (choose to use an HTTPS address)! ! !
(C) s.version The private library version number is generally changed to 1.0.0
3. Upload local private library
1) Create a remote private library on gitlab. Notice! ! ! This library stores remote private library code, don't confuse it with the remote index library! ! !
git remote add origin remote warehouse address ##When the address is not associated, you need to add the associated remote warehouse address
2) Push the local private library to the remote private library
cd to the local private library folder PinnetHeaderSegment and execute
①Build a local git code base
git init
git status ##Check whether the file has been modified since the last submission ( red files indicate that they have not been updated in the cache )
②Update the red file to the cache
git add file name##Upload a single file
git add . ##Upload all files
git status ##The successfully updated file turns green
③ Submit documents
git commit -m 'Commit information'
④ First pull the remote code
git pull origin master
Or git branch --set-upstream-to=origin/master master
The error "fatal: refusing to merge unrelated histories" (that is, project submission histories that do not know each other's existence and have mismatched histories) can be executed by git pull origin master --allow-unrelated-histories
Afterwards, the above command may enter the vi mode. After entering the update information as prompted, press the [ESC] key to jump to the command mode, press the colon key, and then press [wq] to save and exit the vi editing state.
报错fatal: couldn't find remote ref master
There are no files in this warehouse yet. It is empty. You can just push local modifications directly. No pull is needed.
报错 fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Re-cd folder location
git remote add origin remote warehouse address#Associate remote warehouse address
⑤Submit the local cache to the remote code base
Before submitting the modification, confirm again that no modification will be made, modify the tag value in the spec file, and then push
git push -u origin master
Push the version to the master branch (-f forces push and overwrites all previous files)
git push origin master -f
4. Perform local verification
initial command
pod lib lint --verbose --allow-warnings
If you depend on other third-party libraries
pod lib lint --verbose --allow-warnings --sources="cocoapods library address, private library remote address"
If other third-party private libraries depend on other libraries, you need to add --use-libraries
pod lib lint --verbose --use-libraries --allow-warnings --sources="cocoapods library address, private library remote address"
Display xxx passed validation. Indicates that the verification passed
Ps:
--verbose : Some non-grammatical errors do not give the error reason. At this time, you can use it to view the detailed verification process to help locate the error.
--allow-warnings : Indicates that warnings are allowed.
--use-libraries : Indicates the use of static libraries or frameworks. This is mainly used to solve the problem when we rely on some framework libraries and the verification prompt cannot find the library.
--sources='master,privateSpecs' : Specify the source. For example, if your private pod depends on both public and private libraries, you must specify the source, because by default it will only look for the corresponding dependencies in the public source.
报错[!] xxx did not pass validation, due to 1 error.
You need to resolve all errors in the Example project and resubmit it.
ERROR | [iOS] unknown: Encountered an unknown error (CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/all_pods_versions_a_1_5.txt Response: SSL peer certificate or SSH remote key was not OK) during validation.
Execute pod repo remove trunk to delete the following repo source
trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/xxx/.cocoapods/repos/trunk
报错ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for `PinnetBase` depended upon by `PinnetHeaderSegment`
Or report an error
[!] Couldn't determine repo type for URL: `https://xxx/`: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (unable to get local issuer certificate)
Or report an error [!]Found multiple specifications for 'xxx'
Github third-party library execution is not referenced
pod lib lint --verbose --use-libraries --allow-warnings --sources='http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git'
There are references to github third-party libraries for execution
pod lib lint --verbose --use-libraries --allow-warnings --sources='https://github.com/CocoaPods/Specs.git,http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git'
5. Tag
The tag must be consistent with the version number written in the spec file , consistent, consistent! ! ! Anything modified in later versions will need to be re-tagged.
git tag version number (must be consistent with the version number written in the spec file)
git push origin --tags
6.Remote verification
1) After the tag is added, perform remote verification. In fact, it is the same as local verification. How does the local verification pass? The remote only needs to change the lib field to spec. For example, mine
pod spec lint --verbose --allow-warnings
If you depend on other third-party libraries
pod spec lint --verbose --allow-warnings --sources="cocoapods library address, private library remote address"
If other third-party private libraries depend on other libraries, you need to add --use-libraries
pod spec lint --verbose --use-libraries --allow-warnings --sources="cocoapods library address, private library remote address"
Github third-party library execution is not referenced
pod spec lint --verbose --use-libraries --allow-warnings --sources='http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git'
There are references to github third-party libraries for execution
pod spec lint --verbose --use-libraries --allow-warnings --sources='https://github.com/CocoaPods/Specs.git,http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git'
报错- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSearchBar.git /var/folders/sn/56pkr11n0vv91b5q37mjgxf80000gn/T/d20221021-1427-1o5usog --template= --single-branch --depth 1 --branch 1.0.0
Cloning into '/var/folders/sn/56pkr11n0vv91b5q37mjgxf80000gn/T/d20221021-1427-1o5usog'...
warning: Could not find remote branch 1.0.0 to clone.
fatal: Remote branch 1.0.0 not found in upstream origin
Warning: The remote branch 1.0.0 to clone was not found.
fatal: remote branch 1.0.0 not found in upstream source
View the component library tag on gitlab
Go tag first
7. Submit the podspec file to the initially created private index library PinnetSpec
1) After all verifications are passed, the spec file must be pushed to the remote index library created at the beginning.
If an error is reported
[!] Unable to find the `PinnetSpec` repo. If it has not yet been cloned, add it via `pod repo add`.
1. Add source address
pod repo add PinnetSpec http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git
2. Push the spec to the remote
pod repo push [index library name] [component library name].podspec
pod repo push PinnetSpec PinnetBase.podspec --allow-warnings --use-libraries --verbose
报错[!] Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (unable to get local issuer certificate)
First switch to the external network and execute it once, then switch to the internal network and execute it again.
报错The xx.podspec specification does not validate.
Add suffix to the command --allow-warnings --use-libraries --verbose
2) After the final push, the appearance in the local index library is as shown below
3) Verify your private library at this time
Update the pod library first, otherwise the private library you just uploaded will not be found.
pod repo update --
pod search private library name
Use private library
In the Podfile file in the Example folder
1. Add source source path
source 'https://github.com/CocoaPods/Specs.git'
source 'http://code.pinnettech.cn/pinnet/IESP880/IOS/PinnetSpec.git'
2、pod ‘PinnetBase’
Update remote private library (component library)
1. Modify the corresponding library file in the xxx/xxx/Classes folder
2. Update the pod library file of the test project
pod update --no-repo-update
3. Update the configuration information of the xxx.podspec file. The version number tag must be changed.
4. Submit the code to the remote warehouse
git push orgin master
5. Update tag label
git tag x.x.x
git push --tags
6. Verify private library
pod lib lint --private
pod spec lint
7. Update remote and local private index libraries
pod repo push [index library name] [component library name].podspec
Private library image resource processing
· Copy your own image resources directly to the xxKit/xxKit/Assets folder on the desktop (Assets is specially used to store component image resources)
· cd to the Example directory of the desktop component xxKit
cd xxx/Example
pod install